Skip to content

Commit 9c2b618

Browse files
Merge pull request #119 from lsst/tickets/DM-42773
DM-42773: Save value for version when uncommitted changes.
2 parents 30fe544 + 1667c9a commit 9c2b618

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

python/lsst/sconsUtils/installation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,11 @@ def getFingerprint(versionString):
113113
Unique fingerprint of this version. `None` if unavailable.
114114
"""
115115
if versionString.lower() in ("hg", "mercurial"):
116-
fingerprint, modified = hg.guessFingerprint()
116+
fingerprint = hg.guessFingerprint()
117117
elif versionString.lower() in ("git",):
118-
fingerprint, modified = git.guessFingerprint()
118+
fingerprint = git.guessFingerprint()
119119
else:
120-
fingerprint, modified = None, False
121-
122-
if fingerprint and modified:
123-
fingerprint += " *"
120+
fingerprint = None
124121

125122
return fingerprint
126123

python/lsst/sconsUtils/vcs/git.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@
1212

1313

1414
def guessVersionName():
15-
"""Guess a version name
15+
"""Guess a version name.
1616
1717
Returns
1818
-------
1919
name : `str`
2020
Descriptive name of the repository version state.
2121
"""
22+
name = "unknown"
2223

2324
if not os.path.exists(".git"):
24-
state.log.warn("Cannot guess version without .git directory; version will be set to 'unknown'.")
25-
return "unknown"
26-
status = utils.runExternal("git status --porcelain --untracked-files=no", fatal=True)
27-
if status.strip():
28-
raise RuntimeError("Error with git version: uncommitted changes")
29-
desc = utils.runExternal("git describe --tags --always", fatal=True)
30-
return desc.strip()
25+
state.log.warn(f"Cannot guess version without .git directory; will be set to '{name}'.")
26+
else:
27+
name = utils.runExternal("git describe --always --dirty", fatal=False).strip()
28+
29+
return name
3130

3231

3332
def guessFingerprint():
@@ -37,19 +36,14 @@ def guessFingerprint():
3736
-------
3837
fingerprint : `str`
3938
SHA1 of current repository state.
40-
modified : `bool`
41-
Flag to indicate whether the repository is in a modified state.
4239
"""
43-
fingerprint, modified = "0x0", False
40+
fingerprint = "0x0"
4441

4542
if not os.path.exists(".git"):
4643
state.log.warn(f"Cannot guess fingerprint without .git directory; will be set to '{fingerprint}'.")
4744
else:
48-
status = utils.runExternal("git status --porcelain --untracked-files=no", fatal=True)
49-
if status.strip():
50-
modified = True
51-
output = utils.runExternal("git rev-parse HEAD", fatal=False)
52-
53-
fingerprint = output.strip()
45+
fingerprint = utils.runExternal(
46+
"git describe --match=" " --always --abbrev=0 --dirty", fatal=False
47+
).strip()
5448

55-
return fingerprint, modified
49+
return fingerprint

python/lsst/sconsUtils/vcs/hg.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ def guessFingerprint():
5656
-------
5757
fingerprint : `str`
5858
SHA1 of current repository state.
59-
modified : `bool`
60-
Flag to indicate whether the repository is in a modified state.
6159
"""
62-
fingerprint, modified = "0x0", False
60+
fingerprint = "0x0"
6361
if not os.path.exists(".hg"):
6462
state.log.warn(f"Cannot guess fingerprint without .hg directory; will be set to '{fingerprint}'.")
6563
else:
@@ -70,6 +68,6 @@ def guessFingerprint():
7068

7169
fingerprint = utils.runExternal("hg ident --id", fatal=True).strip()
7270
if re.search(r"\+", ident[0]):
73-
modified = True
71+
fingerprint += " *"
7472

75-
return fingerprint, modified
73+
return fingerprint

0 commit comments

Comments
 (0)