From 1d2890e3bb6c5b035ff31c84e7943cf04523abdc Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 8 Aug 2024 19:51:30 -0600 Subject: [PATCH 1/3] Return describe_version to its state prior to ca22dbf I will update it to leverage git-fleximod, but want to use the more extensive python script as a starting point. --- describe_version | 72 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/describe_version b/describe_version index 1c211b8ce5..33dd53518c 100755 --- a/describe_version +++ b/describe_version @@ -1 +1,71 @@ -./bin/git-fleximod status +#!/usr/bin/env python +"""Describes the CESM version and any local modifications""" + +from __future__ import print_function + +import os +import argparse +import subprocess + +def commandline_args(): + """Parse and return command-line arguments + """ + + # We don't really need an argument parser, since there currently aren't any + # arguments. But providing this allows supporting a '--help' option with a + # description. + + description = """ +Script for describing the CESM version and any local modifications + +Simply run: + + ./describe_version + +without any arguments. + +You may want to redirect the output to a file, such as: + + ./describe_version > current_version.txt +""" + + parser = argparse.ArgumentParser( + description=description, + formatter_class=argparse.RawTextHelpFormatter) + + args = parser.parse_args() + return args + +def main(): + """Main function for describe_version""" + # We currently don't actually need any arguments, but call this to allow '--help' usage + _ = commandline_args() + + # Allow this script to run correctly even if invoked from some other directory; note that + # we assume that the script resides in the top level of the CESM checkout. + cesmroot = os.path.dirname(os.path.realpath(__file__)) + + separator = 72*'-' + '\n' + + # The '--long' option to git describe forces it to always show the hash, even if we're + # on a tag. + git_describe = subprocess.check_output(['git', 'describe', '--long'], + cwd=cesmroot, + universal_newlines=True) + print(separator + 'git describe:\n' + git_describe + separator) + + git_status = subprocess.check_output(['git', 'status'], + cwd=cesmroot, + universal_newlines=True) + print(separator + 'git status:\n' + git_status + separator) + + manic = os.path.join('manage_externals', 'checkout_externals') + # Give '--verbose' twice to give very verbose output, showing all modified files in + # each external. + manage_externals_status = subprocess.check_output([manic, '--status', '--verbose', '--verbose'], + cwd=cesmroot, + universal_newlines=True) + print(separator + 'manage_externals status:\n' + manage_externals_status + separator) + +if __name__ == "__main__": + main() From 3cbb02798785cc45ab5b257f0dcce104e8643252 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 8 Aug 2024 20:07:36 -0600 Subject: [PATCH 2/3] Change describe_version to use git-fleximod instead of manage_externals --- describe_version | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/describe_version b/describe_version index 33dd53518c..251bd09b2b 100755 --- a/describe_version +++ b/describe_version @@ -59,13 +59,11 @@ def main(): universal_newlines=True) print(separator + 'git status:\n' + git_status + separator) - manic = os.path.join('manage_externals', 'checkout_externals') - # Give '--verbose' twice to give very verbose output, showing all modified files in - # each external. - manage_externals_status = subprocess.check_output([manic, '--status', '--verbose', '--verbose'], - cwd=cesmroot, - universal_newlines=True) - print(separator + 'manage_externals status:\n' + manage_externals_status + separator) + fleximod = os.path.join('bin', 'git-fleximod') + fleximod_status = subprocess.check_output([fleximod, 'status'], + cwd=cesmroot, + universal_newlines=True) + print(separator + 'git-fleximod status:\n' + fleximod_status + separator) if __name__ == "__main__": main() From e15bd267a3e7781731a2859220b366c74de3a29b Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 9 Aug 2024 09:38:43 -0600 Subject: [PATCH 3/3] Remove unnecessary future import line --- describe_version | 2 -- 1 file changed, 2 deletions(-) diff --git a/describe_version b/describe_version index 251bd09b2b..d652cd839e 100755 --- a/describe_version +++ b/describe_version @@ -1,8 +1,6 @@ #!/usr/bin/env python """Describes the CESM version and any local modifications""" -from __future__ import print_function - import os import argparse import subprocess