This repository was archived by the owner on Apr 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmicropython-patch.diff
38 lines (36 loc) · 2 KB
/
micropython-patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py
index aedc292e4..d51167974 100644
--- a/py/makeversionhdr.py
+++ b/py/makeversionhdr.py
@@ -19,9 +19,11 @@ def get_version_info_from_git():
except AttributeError:
return None
+ cwd = os.path.dirname(sys.argv[0])
+
# Note: git describe doesn't work if no tag is available
try:
- git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], stderr=subprocess.STDOUT, universal_newlines=True).strip()
+ git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], stderr=subprocess.STDOUT, universal_newlines=True, cwd=cwd).strip()
except subprocess.CalledProcessError as er:
if er.returncode == 128:
# git exit code of 128 means no repository found
@@ -30,7 +32,7 @@ def get_version_info_from_git():
except OSError:
return None
try:
- git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.STDOUT, universal_newlines=True).strip()
+ git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.STDOUT, universal_newlines=True, cwd=cwd).strip()
except subprocess.CalledProcessError:
git_hash = "unknown"
except OSError:
@@ -38,9 +40,9 @@ def get_version_info_from_git():
try:
# Check if there are any modified files.
- subprocess.check_call(["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], stderr=subprocess.STDOUT)
+ subprocess.check_call(["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], cwd=cwd, stderr=subprocess.STDOUT)
# Check if there are any staged files.
- subprocess.check_call(["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], stderr=subprocess.STDOUT)
+ subprocess.check_call(["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], cwd=cwd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
git_hash += "-dirty"
except OSError: