From dd73ec29897ae5c3c950981621f800e52161ca4c Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 10:18:33 -0600 Subject: [PATCH 1/8] add git-fleximod ci test --- .github/workflows/fleximod_test.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/fleximod_test.yaml diff --git a/.github/workflows/fleximod_test.yaml b/.github/workflows/fleximod_test.yaml new file mode 100644 index 00000000..24bcac95 --- /dev/null +++ b/.github/workflows/fleximod_test.yaml @@ -0,0 +1,24 @@ +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + fleximod-test: + runs-on: ubuntu-latest + strategy: + matrix: + # oldest supported and latest supported + python-version: ["3.7", "3.x"] + steps: + - id: checkout-CESM + uses: actions/checkout@v4 + - id: run-fleximod + run: | + $GITHUB_WORKSPACE/bin/git-fleximod update + $GITHUB_WORKSPACE/bin/git-fleximod test +# - name: Setup tmate session +# if: ${{ failure() }} +# uses: mxschmitt/action-tmate@v3 + + From 68a9ba8b520b0d61dd54d6c67625122a7a1bb624 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 10:22:29 -0600 Subject: [PATCH 2/8] point to correct branch --- .github/workflows/fleximod_test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/fleximod_test.yaml b/.github/workflows/fleximod_test.yaml index 24bcac95..dde87d52 100644 --- a/.github/workflows/fleximod_test.yaml +++ b/.github/workflows/fleximod_test.yaml @@ -1,8 +1,6 @@ on: - push: - branches: [ master ] pull_request: - branches: [ master ] + branches: [ development ] jobs: fleximod-test: runs-on: ubuntu-latest From ba7746fd573066fbb0ee736a23f03c48a2654fa3 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 10:36:41 -0600 Subject: [PATCH 3/8] update to git-fleximod v8.3 --- .lib/git-fleximod/git_fleximod/cli.py | 2 +- .../git-fleximod/git_fleximod/git_fleximod.py | 15 +++++----- .lib/git-fleximod/git_fleximod/submodule.py | 29 +++++++++++++------ .lib/git-fleximod/pyproject.toml | 2 +- .lib/git-fleximod/tbump.toml | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.lib/git-fleximod/git_fleximod/cli.py b/.lib/git-fleximod/git_fleximod/cli.py index fdcf102a..b7bc8078 100644 --- a/.lib/git-fleximod/git_fleximod/cli.py +++ b/.lib/git-fleximod/git_fleximod/cli.py @@ -2,7 +2,7 @@ import argparse from git_fleximod import utils -__version__ = "0.8.2" +__version__ = "0.8.3" def find_root_dir(filename=".gitmodules"): """ finds the highest directory in tree diff --git a/.lib/git-fleximod/git_fleximod/git_fleximod.py b/.lib/git-fleximod/git_fleximod/git_fleximod.py index 4595cd2a..50e0ef83 100755 --- a/.lib/git-fleximod/git_fleximod/git_fleximod.py +++ b/.lib/git-fleximod/git_fleximod/git_fleximod.py @@ -195,18 +195,19 @@ def submodules_status(gitmodules, root_dir, toplevel=False, depth=0): submod = init_submodule_from_gitmodules(gitmodules, name, root_dir, logger) result,n,l,t = submod.status() - testfails += t - localmods += l - needsupdate += n if toplevel or not submod.toplevel(): print(wrapper.fill(result)) - subdir = os.path.join(root_dir, submod.path) - if os.path.exists(os.path.join(subdir, ".gitmodules")): - submod = GitModules(logger, confpath=subdir) - t,l,n = submodules_status(submod, subdir, depth=depth+1) testfails += t localmods += l needsupdate += n + subdir = os.path.join(root_dir, submod.path) + if os.path.exists(os.path.join(subdir, ".gitmodules")): + gsubmod = GitModules(logger, confpath=subdir) + t,l,n = submodules_status(gsubmod, subdir, depth=depth+1) + if toplevel or not submod.toplevel(): + testfails += t + localmods += l + needsupdate += n return testfails, localmods, needsupdate diff --git a/.lib/git-fleximod/git_fleximod/submodule.py b/.lib/git-fleximod/git_fleximod/submodule.py index 48657272..52633c7c 100644 --- a/.lib/git-fleximod/git_fleximod/submodule.py +++ b/.lib/git-fleximod/git_fleximod/submodule.py @@ -92,7 +92,7 @@ def status(self): needsupdate = True else: result = f"e {self.name:>20} has no fxtag defined in .gitmodules{optional}" - testfails = True + testfails = False else: with utils.pushd(smpath): git = GitInterface(smpath, self.logger) @@ -106,10 +106,16 @@ def status(self): line = git.git_operation("log", "--pretty=format:\"%h %d").partition('\n')[0] parts = line.split() ahash = parts[0][1:] + atag = None if len(parts) > 3: - atag = parts[3][:-1] - else: - atag = None + idx = 0 + while idx < len(parts)-1: + idx = idx+1 + if parts[idx] == 'tag:': + atag = parts[idx+1][:-1] + if atag == self.fxtag: + break + #print(f"line is {line} ahash is {ahash} atag is {atag}") # atag = git.git_operation("describe", "--tags", "--always").rstrip() @@ -122,9 +128,11 @@ def status(self): if self.fxtag and atag == self.fxtag: result = f" {self.name:>20} at tag {self.fxtag}" recurse = True + testfails = False elif self.fxtag and ahash[: len(self.fxtag)] == self.fxtag: result = f" {self.name:>20} at hash {ahash}" recurse = True + testfails = False elif atag == ahash: result = f" {self.name:>20} at hash {ahash}" recurse = True @@ -133,14 +141,17 @@ def status(self): testfails = True needsupdate = True else: - result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {atag}" - testfails = True - + if atag: + result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {atag}" + else: + result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {ahash}" + testfails = False + status = git.git_operation("status", "--ignore-submodules", "-uno") if "nothing to commit" not in status: localmods = True - result = "M" + textwrap.indent(status, " ") - + result = "M" + textwrap.indent(status, " " +# print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}") return result, needsupdate, localmods, testfails diff --git a/.lib/git-fleximod/pyproject.toml b/.lib/git-fleximod/pyproject.toml index 9cff1423..7b0354bd 100644 --- a/.lib/git-fleximod/pyproject.toml +++ b/.lib/git-fleximod/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "git-fleximod" -version = "0.8.2" +version = "0.8.3" description = "Extended support for git-submodule and git-sparse-checkout" authors = ["Jim Edwards "] maintainers = ["Jim Edwards "] diff --git a/.lib/git-fleximod/tbump.toml b/.lib/git-fleximod/tbump.toml index b4eed7d4..3b6813a2 100644 --- a/.lib/git-fleximod/tbump.toml +++ b/.lib/git-fleximod/tbump.toml @@ -2,7 +2,7 @@ github_url = "https://github.com/jedwards4b/git-fleximod/" [version] -current = "0.8.2" +current = "0.8.3" # Example of a semver regexp. # Make sure this matches current_version before From 7fd861ce1fb5961c642656b3a282273e03c4070f Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 10:37:55 -0600 Subject: [PATCH 4/8] fix indent --- .lib/git-fleximod/git_fleximod/submodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lib/git-fleximod/git_fleximod/submodule.py b/.lib/git-fleximod/git_fleximod/submodule.py index 52633c7c..5d92f6a9 100644 --- a/.lib/git-fleximod/git_fleximod/submodule.py +++ b/.lib/git-fleximod/git_fleximod/submodule.py @@ -141,7 +141,7 @@ def status(self): testfails = True needsupdate = True else: - if atag: + if atag: result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {atag}" else: result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {ahash}" From d17ecdd0b583f77fa96312bd0d2f7f0d7376e753 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 10:41:51 -0600 Subject: [PATCH 5/8] fix unclosed parenthesis --- .lib/git-fleximod/git_fleximod/submodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lib/git-fleximod/git_fleximod/submodule.py b/.lib/git-fleximod/git_fleximod/submodule.py index 5d92f6a9..b5918de8 100644 --- a/.lib/git-fleximod/git_fleximod/submodule.py +++ b/.lib/git-fleximod/git_fleximod/submodule.py @@ -150,7 +150,7 @@ def status(self): status = git.git_operation("status", "--ignore-submodules", "-uno") if "nothing to commit" not in status: localmods = True - result = "M" + textwrap.indent(status, " " + result = "M" + textwrap.indent(status, " ") # print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}") return result, needsupdate, localmods, testfails From 5194016a4d62d93f064fb0d69daaa51aeb43324b Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 12:05:35 -0600 Subject: [PATCH 6/8] fix from jim --- .lib/git-fleximod/git_fleximod/submodule.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.lib/git-fleximod/git_fleximod/submodule.py b/.lib/git-fleximod/git_fleximod/submodule.py index b5918de8..70a3018a 100644 --- a/.lib/git-fleximod/git_fleximod/submodule.py +++ b/.lib/git-fleximod/git_fleximod/submodule.py @@ -103,7 +103,7 @@ def status(self): needsupdate = True return result, needsupdate, localmods, testfails rurl = git.git_operation("ls-remote","--get-url").rstrip() - line = git.git_operation("log", "--pretty=format:\"%h %d").partition('\n')[0] + line = git.git_operation("log", "--pretty=format:\"%h %d\"").partition('\n')[0] parts = line.split() ahash = parts[0][1:] atag = None @@ -112,12 +112,14 @@ def status(self): while idx < len(parts)-1: idx = idx+1 if parts[idx] == 'tag:': - atag = parts[idx+1][:-1] + atag = parts[idx+1] + while atag.endswith(')') or atag.endswith(',') or atag.endswith("\""): + atag = atag[:-1] if atag == self.fxtag: break - #print(f"line is {line} ahash is {ahash} atag is {atag}") + #print(f"line is {line} ahash is {ahash} atag is {atag} {parts}") # atag = git.git_operation("describe", "--tags", "--always").rstrip() # ahash = git.git_operation("rev-list", "HEAD").partition("\n")[0] @@ -129,7 +131,7 @@ def status(self): result = f" {self.name:>20} at tag {self.fxtag}" recurse = True testfails = False - elif self.fxtag and ahash[: len(self.fxtag)] == self.fxtag: + elif self.fxtag and (ahash[: len(self.fxtag)] == self.fxtag or (self.fxtag.find(ahash)==0)): result = f" {self.name:>20} at hash {ahash}" recurse = True testfails = False @@ -146,7 +148,7 @@ def status(self): else: result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {ahash}" testfails = False - + status = git.git_operation("status", "--ignore-submodules", "-uno") if "nothing to commit" not in status: localmods = True From 2c50bb0742d03f2fc929fc9030be5e7598ee6d5a Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 25 Jul 2024 13:13:58 -0600 Subject: [PATCH 7/8] update to v8.4 --- .lib/git-fleximod/git_fleximod/cli.py | 2 +- .lib/git-fleximod/pyproject.toml | 2 +- .lib/git-fleximod/tbump.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.lib/git-fleximod/git_fleximod/cli.py b/.lib/git-fleximod/git_fleximod/cli.py index b7bc8078..b6f728f8 100644 --- a/.lib/git-fleximod/git_fleximod/cli.py +++ b/.lib/git-fleximod/git_fleximod/cli.py @@ -2,7 +2,7 @@ import argparse from git_fleximod import utils -__version__ = "0.8.3" +__version__ = "0.8.4" def find_root_dir(filename=".gitmodules"): """ finds the highest directory in tree diff --git a/.lib/git-fleximod/pyproject.toml b/.lib/git-fleximod/pyproject.toml index 7b0354bd..850e57d5 100644 --- a/.lib/git-fleximod/pyproject.toml +++ b/.lib/git-fleximod/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "git-fleximod" -version = "0.8.3" +version = "0.8.4" description = "Extended support for git-submodule and git-sparse-checkout" authors = ["Jim Edwards "] maintainers = ["Jim Edwards "] diff --git a/.lib/git-fleximod/tbump.toml b/.lib/git-fleximod/tbump.toml index 3b6813a2..bd82c557 100644 --- a/.lib/git-fleximod/tbump.toml +++ b/.lib/git-fleximod/tbump.toml @@ -2,7 +2,7 @@ github_url = "https://github.com/jedwards4b/git-fleximod/" [version] -current = "0.8.3" +current = "0.8.4" # Example of a semver regexp. # Make sure this matches current_version before From 9fd05284f6b52f9954fd4a551977572ac719d0b4 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Mon, 12 Aug 2024 09:53:10 -0600 Subject: [PATCH 8/8] update workflow, use python 3.8 as oldest version --- .github/workflows/fleximod_test.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/fleximod_test.yaml b/.github/workflows/fleximod_test.yaml index dde87d52..36e68b19 100644 --- a/.github/workflows/fleximod_test.yaml +++ b/.github/workflows/fleximod_test.yaml @@ -1,13 +1,12 @@ on: pull_request: - branches: [ development ] jobs: fleximod-test: runs-on: ubuntu-latest strategy: matrix: # oldest supported and latest supported - python-version: ["3.7", "3.x"] + python-version: ["3.8", "3.x"] steps: - id: checkout-CESM uses: actions/checkout@v4 @@ -15,8 +14,5 @@ jobs: run: | $GITHUB_WORKSPACE/bin/git-fleximod update $GITHUB_WORKSPACE/bin/git-fleximod test -# - name: Setup tmate session -# if: ${{ failure() }} -# uses: mxschmitt/action-tmate@v3