blob: 3f16ce98ba442da38bfdfe803856d4ac963d7058 [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():
10 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
18
19 # 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'