Skip to content

Commit 3e5cc77

Browse files
authored
add option for makebuildsources to specify the style arguments for 'git describe'. (AMReX-Codes#2957)
1 parent a6e0c11 commit 3e5cc77

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Tools/C_scripts/makebuildinfo_C.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ def runcommand(command):
186186
out = p.stdout.read()
187187
return out.strip().decode("ascii")
188188

189-
def get_git_hash(d):
189+
def get_git_hash(d, git_style):
190190
cwd = os.getcwd()
191191
os.chdir(d)
192192
try:
193-
ghash = runcommand("git describe --always --tags --dirty")
193+
ghash = runcommand("git describe " + git_style)
194194
except:
195195
ghash = ""
196196
os.chdir(cwd)
@@ -259,6 +259,10 @@ def get_git_hash(d):
259259
help="the full path to the build directory that corresponds to build_git_name",
260260
type=str, default="")
261261

262+
parser.add_argument("--GIT_STYLE",
263+
help="style options for the 'git describe' command used to construct hash strings",
264+
type=str, default="--always --tags --dirty")
265+
262266

263267
# parse and convert to a dictionary
264268
args = parser.parse_args()
@@ -281,7 +285,7 @@ def get_git_hash(d):
281285
git_hashes = []
282286
for d in GIT:
283287
if d and os.path.isdir(d):
284-
git_hashes.append(get_git_hash(d))
288+
git_hashes.append(get_git_hash(d, args.GIT_STYLE))
285289
else:
286290
git_hashes.append("")
287291

@@ -291,7 +295,7 @@ def get_git_hash(d):
291295
except:
292296
build_git_hash = "directory not valid"
293297
else:
294-
build_git_hash = get_git_hash(args.build_git_dir)
298+
build_git_hash = get_git_hash(args.build_git_dir, args.GIT_STYLE)
295299
os.chdir(running_dir)
296300
else:
297301
build_git_hash = ""

0 commit comments

Comments
 (0)