Skip to content

Commit

Permalink
add option for makebuildsources to specify the style arguments for 'g…
Browse files Browse the repository at this point in the history
…it describe'. (AMReX-Codes#2957)
  • Loading branch information
dwillcox committed Sep 21, 2022
1 parent a6e0c11 commit 3e5cc77
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Tools/C_scripts/makebuildinfo_C.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ def runcommand(command):
out = p.stdout.read()
return out.strip().decode("ascii")

def get_git_hash(d):
def get_git_hash(d, git_style):
cwd = os.getcwd()
os.chdir(d)
try:
ghash = runcommand("git describe --always --tags --dirty")
ghash = runcommand("git describe " + git_style)
except:
ghash = ""
os.chdir(cwd)
Expand Down Expand Up @@ -259,6 +259,10 @@ def get_git_hash(d):
help="the full path to the build directory that corresponds to build_git_name",
type=str, default="")

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


# parse and convert to a dictionary
args = parser.parse_args()
Expand All @@ -281,7 +285,7 @@ def get_git_hash(d):
git_hashes = []
for d in GIT:
if d and os.path.isdir(d):
git_hashes.append(get_git_hash(d))
git_hashes.append(get_git_hash(d, args.GIT_STYLE))
else:
git_hashes.append("")

Expand All @@ -291,7 +295,7 @@ def get_git_hash(d):
except:
build_git_hash = "directory not valid"
else:
build_git_hash = get_git_hash(args.build_git_dir)
build_git_hash = get_git_hash(args.build_git_dir, args.GIT_STYLE)
os.chdir(running_dir)
else:
build_git_hash = ""
Expand Down

0 comments on commit 3e5cc77

Please sign in to comment.