Revert "Extract searching relevat files in utils function"
This reverts commit 512fd3bd855fe001443ee3328d139da8c4b95d00.
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>
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..3f16ce9
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,25 @@
+# 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'