Files
chromium_depot_tools/utils.py
Josip Sokcevic a9a7eecf37 Revert "Extract searching relevat files in utils function"
This reverts commit 512fd3bd85.

Reason for revert: breaks some presubmits
https://crbug.com/1421441

Original change's description:
> Extract searching relevat files in utils function
>
> This change introduces lib/ directory which will be used for classes
> that are considered libraries and used by multiple executables.
>
> Change-Id: I3da126778bf5ffdb28d7a3c2b966c85de08ba717
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4289679
> Reviewed-by: Joanna Wang <jojwang@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>

Bug: 1421441
Change-Id: I20e40f452a544a1188a258131a620e2afcd64f13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4328468
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2023-03-10 03:54:52 +00:00

26 lines
833 B
Python

# Copyright 2022 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import subprocess
def depot_tools_version():
depot_tools_root = os.path.dirname(os.path.abspath(__file__))
try:
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'],
cwd=depot_tools_root).decode(
'utf-8', 'ignore')
return 'git-%s' % commit_hash
except Exception:
pass
# git check failed, let's check last modification of frequently checked file
try:
mtime = os.path.getmtime(
os.path.join(depot_tools_root, 'infra', 'config', 'recipes.cfg'))
return 'recipes.cfg-%d' % (mtime)
except Exception:
return 'unknown'