blob: a85d2f722eb4177705ad4a2927ed371d185a74bf [file] [log] [blame]
Josip Sokcevica9a7eec2023-03-10 03:54:52 +00001# Copyright 2022 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import os
6import subprocess
7
8
9def depot_tools_version():
Mike Frysinger124bb8e2023-09-06 05:48:55 +000010 depot_tools_root = os.path.dirname(os.path.abspath(__file__))
11 try:
12 commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'],
13 cwd=depot_tools_root).decode(
14 'utf-8', 'ignore')
15 return 'git-%s' % commit_hash
16 except Exception:
17 pass
Josip Sokcevica9a7eec2023-03-10 03:54:52 +000018
Mike Frysinger124bb8e2023-09-06 05:48:55 +000019 # git check failed, let's check last modification of frequently checked file
20 try:
21 mtime = os.path.getmtime(
22 os.path.join(depot_tools_root, 'infra', 'config', 'recipes.cfg'))
23 return 'recipes.cfg-%d' % (mtime)
24 except Exception:
25 return 'unknown'