-
Notifications
You must be signed in to change notification settings - Fork 169
cam6_4_049: History bugfixes #1163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
peverwhee
merged 26 commits into
ESCOMP:cam_development
from
peverwhee:history-bugfixes
Dec 31, 2024
Merged
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4c96ed5
return all indices and check for duplicates
3acb4b2
update to git-fleximod 0.9.2
5c343d9
remove duplicate fields from use cases
8abd7cf
change methodology to allow for duplicate fields with the same flag
33b6ffb
code cleanup; fix bad comment
b29a8de
revert duplicate removal
31e7e6b
improve error handling
ca13895
remove reference to tapes
b960ffb
don't error all the time perhaps
7b04a6e
Merge remote-tracking branch 'ESCOMP/cam_development' into history-bu…
225f7e3
add sampled_on_subcycle flag and remove time_bounds field from instan…
34e9816
move file-dependent fields to end of if block
peverwhee ba1e652
fix filename for instantaneous monthly files
peverwhee b8cd5a6
Merge remote-tracking branch 'ESCOMP/cam_development' into history-bu…
peverwhee 2f59d18
add sampled_on_subcycle argument for missing subcycle fields
peverwhee f820ab6
remove "prev" argument for inst files; move open file logging to befo…
peverwhee 3441f59
Merge remote-tracking branch 'ESCOMP/cam_development' into history-bu…
peverwhee 03c0a0f
initial changelog
peverwhee cdcbea5
update archive_baseline script to modify read permissions on izumi
51d1e07
Merge branch 'history-bugfixes' of https://github.com/peverwhee/CAM i…
a9441a8
update git-fleximod to 0.9.3
peverwhee 99dbe11
merge to head of cam_development
peverwhee 3548dcf
update submodules
peverwhee d60dbc2
update cime tag to fix restarts issue
2d12f78
update cime
c3c9ed2
final changelog
peverwhee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,8 +60,9 @@ def status(self): | |
| if not os.path.exists(os.path.join(smpath, ".git")): | ||
| rootgit = GitInterface(self.root_dir, self.logger) | ||
| # submodule commands use path, not name | ||
| tags = rootgit.git_operation("ls-remote", "--tags", self.url) | ||
| result = rootgit.git_operation("submodule","status",smpath).split() | ||
| status, tags = rootgit.git_operation("ls-remote", "--tags", self.url) | ||
| status, result = rootgit.git_operation("submodule","status",smpath) | ||
| result = result.split() | ||
|
|
||
| if result: | ||
| ahash = result[0][1:] | ||
|
|
@@ -80,9 +81,9 @@ def status(self): | |
| result = f"e {self.name:>20} not checked out, aligned at tag {self.fxtag}{optional}" | ||
| needsupdate = True | ||
| elif self.fxtag: | ||
| ahash = rootgit.git_operation( | ||
| status, ahash = rootgit.git_operation( | ||
| "submodule", "status", "{}".format(self.path) | ||
| ).rstrip() | ||
| ) | ||
| ahash = ahash[1 : len(self.fxtag) + 1] | ||
| if self.fxtag == ahash: | ||
| result = f"e {self.name:>20} not checked out, aligned at hash {ahash}{optional}" | ||
|
|
@@ -96,14 +97,15 @@ def status(self): | |
| else: | ||
| with utils.pushd(smpath): | ||
| git = GitInterface(smpath, self.logger) | ||
| remote = git.git_operation("remote").rstrip() | ||
| status, remote = git.git_operation("remote") | ||
| if remote == '': | ||
| result = f"e {self.name:>20} has no associated remote" | ||
| testfails = True | ||
| 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] | ||
| status, rurl = git.git_operation("ls-remote","--get-url") | ||
| status, lines = git.git_operation("log", "--pretty=format:\"%h %d\"") | ||
| line = lines.partition('\n')[0] | ||
| parts = line.split() | ||
| ahash = parts[0][1:] | ||
| atag = None | ||
|
|
@@ -120,7 +122,7 @@ def status(self): | |
|
|
||
|
|
||
| #print(f"line is {line} ahash is {ahash} atag is {atag} {parts}") | ||
| # atag = git.git_operation("describe", "--tags", "--always").rstrip() | ||
| # atag = git.git_operation("describe", "--tags", "--always") | ||
| # ahash = git.git_operation("rev-list", "HEAD").partition("\n")[0] | ||
|
|
||
| recurse = False | ||
|
|
@@ -149,10 +151,10 @@ def status(self): | |
| 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: | ||
| status, output = git.git_operation("status", "--ignore-submodules", "-uno") | ||
| if "nothing to commit" not in output: | ||
| localmods = True | ||
| result = "M" + textwrap.indent(status, " ") | ||
| result = "M" + textwrap.indent(output, " ") | ||
| # print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}") | ||
| return result, needsupdate, localmods, testfails | ||
|
|
||
|
|
@@ -171,10 +173,11 @@ def _add_remote(self, git): | |
| Returns: | ||
| str: The name of the new remote if added, or the name of the existing remote that matches the submodule's URL. | ||
| """ | ||
| remotes = git.git_operation("remote", "-v").splitlines() | ||
| status, remotes = git.git_operation("remote", "-v") | ||
| remotes = remotes.splitlines() | ||
| upstream = None | ||
| if remotes: | ||
| upstream = git.git_operation("ls-remote", "--get-url").rstrip() | ||
| status, upstream = git.git_operation("ls-remote", "--get-url") | ||
| newremote = "newremote.00" | ||
| tmpurl = self.url.replace("[email protected]:", "https://github.com/") | ||
| line = next((s for s in remotes if self.url in s or tmpurl in s), None) | ||
|
|
@@ -183,7 +186,7 @@ def _add_remote(self, git): | |
| return newremote | ||
| else: | ||
| i = 0 | ||
| while "newremote" in remotes: | ||
| while newremote in remotes: | ||
| i = i + 1 | ||
| newremote = f"newremote.{i:02d}" | ||
| else: | ||
|
|
@@ -214,12 +217,19 @@ def sparse_checkout(self): | |
| """ | ||
| self.logger.info("Called sparse_checkout for {}".format(self.name)) | ||
| rgit = GitInterface(self.root_dir, self.logger) | ||
| superroot = rgit.git_operation("rev-parse", "--show-superproject-working-tree") | ||
| status, superroot = rgit.git_operation("rev-parse", "--show-superproject-working-tree") | ||
| if superroot: | ||
| gitroot = superroot.strip() | ||
| else: | ||
| gitroot = self.root_dir.strip() | ||
| assert os.path.isdir(os.path.join(gitroot, ".git")) | ||
| # Now need to move the .git dir to the submodule location | ||
| rootdotgit = os.path.join(self.root_dir, ".git") | ||
| while os.path.isfile(rootdotgit): | ||
| with open(rootdotgit) as f: | ||
| line = f.readline().rstrip() | ||
| if line.startswith("gitdir: "): | ||
| rootdotgit = os.path.abspath(os.path.join(self.root_dir,line[8:])) | ||
| assert os.path.isdir(rootdotgit) | ||
| # first create the module directory | ||
| if not os.path.isdir(os.path.join(self.root_dir, self.path)): | ||
| os.makedirs(os.path.join(self.root_dir, self.path)) | ||
|
|
@@ -244,8 +254,8 @@ def sparse_checkout(self): | |
| # set the repository remote | ||
|
|
||
| self.logger.info("Setting remote origin in {}/{}".format(self.root_dir, self.path)) | ||
| status = sprepo_git.git_operation("remote", "-v") | ||
| if self.url not in status: | ||
| status, remotes = sprepo_git.git_operation("remote", "-v") | ||
| if self.url not in remotes: | ||
| sprepo_git.git_operation("remote", "add", "origin", self.url) | ||
|
|
||
| topgit = os.path.join(gitroot, ".git") | ||
|
|
@@ -256,46 +266,46 @@ def sparse_checkout(self): | |
| os.path.join(self.root_dir, f.read().split()[1]), | ||
| start=os.path.join(self.root_dir, self.path), | ||
| ) | ||
| topgit = os.path.join(gitpath, "modules") | ||
| rootdotgit = os.path.join(gitpath, "modules", self.name) | ||
| else: | ||
| topgit = os.path.relpath( | ||
| os.path.join(self.root_dir, ".git", "modules"), | ||
| rootdotgit = os.path.relpath( | ||
| os.path.join(self.root_dir, ".git", "modules", self.name), | ||
| start=os.path.join(self.root_dir, self.path), | ||
| ) | ||
|
|
||
| with utils.pushd(sprep_repo): | ||
| if not os.path.isdir(topgit): | ||
| os.makedirs(topgit) | ||
| topgit += os.sep + self.name | ||
|
|
||
| if os.path.isdir(os.path.join(self.root_dir, self.path, ".git")): | ||
| with utils.pushd(sprep_repo): | ||
| if os.path.isdir(os.path.join(topgit,".git")): | ||
| shutil.rmtree(os.path.join(topgit,".git")) | ||
| shutil.move(".git", topgit) | ||
| if os.path.isdir(os.path.join(rootdotgit,".git")): | ||
| shutil.rmtree(os.path.join(rootdotgit,".git")) | ||
| shutil.move(".git", rootdotgit) | ||
| with open(".git", "w") as f: | ||
| f.write("gitdir: " + os.path.relpath(topgit)) | ||
| # assert(os.path.isdir(os.path.relpath(topgit, start=sprep_repo))) | ||
| gitsparse = os.path.abspath(os.path.join(topgit, "info", "sparse-checkout")) | ||
| f.write("gitdir: " + os.path.relpath(rootdotgit)) | ||
| infodir = os.path.join(rootdotgit, "info") | ||
| if not os.path.isdir(infodir): | ||
| os.makedirs(infodir) | ||
| gitsparse = os.path.abspath(os.path.join(infodir, "sparse-checkout")) | ||
| if os.path.isfile(gitsparse): | ||
| self.logger.warning( | ||
| "submodule {} is already initialized {}".format(self.name, topgit) | ||
| "submodule {} is already initialized {}".format(self.name, rootdotgit) | ||
| ) | ||
| return | ||
|
|
||
| with utils.pushd(sprep_repo): | ||
| if os.path.isfile(self.fxsparse): | ||
|
|
||
| shutil.copy(self.fxsparse, gitsparse) | ||
|
|
||
|
|
||
| # Finally checkout the repo | ||
| sprepo_git.git_operation("fetch", "origin", "--tags") | ||
| sprepo_git.git_operation("checkout", self.fxtag) | ||
|
|
||
| print(f"Successfully checked out {self.name:>20} at {self.fxtag}") | ||
| rgit.config_set_value(f'submodule "{self.name}"', "active", "true") | ||
| rgit.config_set_value(f'submodule "{self.name}"', "url", self.url) | ||
| rgit.config_set_value(f'submodule "{self.name}"', "path", self.path) | ||
| status,_ = sprepo_git.git_operation("checkout", self.fxtag) | ||
| if status: | ||
| print(f"Error checking out {self.name:>20} at {self.fxtag}") | ||
| else: | ||
| print(f"Successfully checked out {self.name:>20} at {self.fxtag}") | ||
| rgit.config_set_value('submodule.' + self.name, "active", "true") | ||
| rgit.config_set_value('submodule.' + self.name, "url", self.url) | ||
| rgit.config_set_value('submodule.' + self.name, "path", self.path) | ||
|
|
||
| def update(self): | ||
| """ | ||
|
|
@@ -342,15 +352,15 @@ def update(self): | |
| git.git_operation("clone", self.url, self.path) | ||
| smgit = GitInterface(repodir, self.logger) | ||
| if not tag: | ||
| tag = smgit.git_operation("describe", "--tags", "--always").rstrip() | ||
| status, tag = smgit.git_operation("describe", "--tags", "--always") | ||
| smgit.git_operation("checkout", tag) | ||
| # Now need to move the .git dir to the submodule location | ||
| rootdotgit = os.path.join(self.root_dir, ".git") | ||
| if os.path.isfile(rootdotgit): | ||
| with open(rootdotgit) as f: | ||
| line = f.readline() | ||
| if line.startswith("gitdir: "): | ||
| rootdotgit = line[8:].rstrip() | ||
| rootdotgit = line[8:] | ||
|
|
||
| newpath = os.path.abspath(os.path.join(self.root_dir, rootdotgit, "modules", self.name)) | ||
| if os.path.exists(newpath): | ||
|
|
@@ -393,15 +403,16 @@ def update(self): | |
| git = GitInterface(submoddir, self.logger) | ||
| # first make sure the url is correct | ||
| newremote = self._add_remote(git) | ||
| tags = git.git_operation("tag", "-l") | ||
| status, tags = git.git_operation("tag", "-l") | ||
| fxtag = self.fxtag | ||
| if fxtag and fxtag not in tags: | ||
| git.git_operation("fetch", newremote, "--tags") | ||
| atag = git.git_operation("describe", "--tags", "--always").rstrip() | ||
| status, atag = git.git_operation("describe", "--tags", "--always") | ||
| if fxtag and fxtag != atag: | ||
| try: | ||
| git.git_operation("checkout", fxtag) | ||
| print(f"{self.name:>20} updated to {fxtag}") | ||
| status, _ = git.git_operation("checkout", fxtag) | ||
| if not status: | ||
| print(f"{self.name:>20} updated to {fxtag}") | ||
| except Exception as error: | ||
| print(error) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [tool.poetry] | ||
| name = "git-fleximod" | ||
| version = "0.8.4" | ||
| version = "0.9.2" | ||
| description = "Extended support for git-submodule and git-sparse-checkout" | ||
| authors = ["Jim Edwards <[email protected]>"] | ||
| maintainers = ["Jim Edwards <[email protected]>"] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.