Josip Sokcevic | a9a7eec | 2023-03-10 03:54:52 +0000 | [diff] [blame] | 1 | # 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 | |
| 5 | import os |
| 6 | import subprocess |
| 7 | |
| 8 | |
| 9 | def depot_tools_version(): |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 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 |
Josip Sokcevic | a9a7eec | 2023-03-10 03:54:52 +0000 | [diff] [blame] | 18 | |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 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' |