diff options
author | Ivan Frade <ifrade@google.com> | 2024-05-30 10:56:20 -0700 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2024-05-30 14:17:53 -0700 |
commit | 1dd6324d4b4d9596813b18a44e315295f559ea12 (patch) | |
tree | 58cab9416465d0d7932d67b48a8f1021d4acbc8d /org.eclipse.jgit/src/org/eclipse/jgit/gitrepo | |
parent | 9b2fe85c0279f4d5ac69f07ddcd48566c3555405 (diff) | |
download | jgit-1dd6324d4b4d9596813b18a44e315295f559ea12.tar.gz jgit-1dd6324d4b4d9596813b18a44e315295f559ea12.zip |
RepoProject: read the "upstream" attribute of a project
The manifest spec [1] defines the "upstream" attribute: "name of the
git ref in which a sha1 can be found", when the revision is a
sha1. The parser is ignoring it, but RepoCommand could use it to
populate the "ref=" field of pinned submodules.
Parse the value and store it in the RepoProject.
RepoProject is public API and the current constructors are not
telescopic, so we cannot just add a new constructor with an extra
argument. Use plain getter/setters.j
[1] https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md#Element-project
Change-Id: Ia50b85b95bfd3710f9fbda2050be5950dd686941
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/gitrepo')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java index 957b3869f2..7402c760c3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java @@ -176,6 +176,8 @@ public class ManifestParser extends DefaultHandler { attributes.getValue("groups")); currentProject .setRecommendShallow(attributes.getValue("clone-depth")); + currentProject + .setUpstream(attributes.getValue("upstream")); break; case "remote": String alias = attributes.getValue("alias"); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java index 8deb7386a6..aa1af21d23 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java @@ -38,6 +38,7 @@ public class RepoProject implements Comparable<RepoProject> { private final Set<String> groups; private final List<CopyFile> copyfiles; private final List<LinkFile> linkfiles; + private String upstream; private String recommendShallow; private String url; private String defaultRevision; @@ -389,6 +390,31 @@ public class RepoProject implements Comparable<RepoProject> { this.linkfiles.clear(); } + /** + * Return the upstream attribute of the project + * + * @return the upstream value if present, null otherwise. + * + * @since 6.10 + */ + public String getUpstream() { + return this.upstream; + } + + /** + * Set the upstream attribute of the project + * + * Name of the git ref in which a sha1 can be found, when the revision is a + * sha1. + * + * @param upstream value of the attribute in the manifest + * + * @since 6.10 + */ + void setUpstream(String upstream) { + this.upstream = upstream; + } + private String getPathWithSlash() { if (path.endsWith("/")) { //$NON-NLS-1$ return path; |