Skip to content

Commit

Permalink
Annotate deprecated methods
Browse files Browse the repository at this point in the history
Reduce compiler warnings about deprecations and declare them consistently.
  • Loading branch information
MarkEWaite committed Sep 17, 2024
1 parent 78c7552 commit ba0ae58
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public <T> T withRepository(RepositoryCallback<T> callable) throws GitException,
}

/** {@inheritDoc} */
@Deprecated
@Override
public void commit(String message, PersonIdent author, PersonIdent committer)
throws GitException, InterruptedException {
Expand All @@ -55,6 +56,7 @@ public void setCommitter(PersonIdent p) throws GitException {
}

/** {@inheritDoc} */
@Deprecated
@Override
public void changelog(String revFrom, String revTo, OutputStream outputStream)
throws GitException, InterruptedException {
Expand All @@ -79,12 +81,14 @@ public void clone(String url, String origin, boolean useShallowClone, String ref
}

/** {@inheritDoc} */
@Deprecated
@Override
public void checkout(String commit) throws GitException, InterruptedException {
checkout().ref(commit).execute();
}

/** {@inheritDoc} */
@Deprecated
@Override
public void checkout(String ref, String branch) throws GitException, InterruptedException {
checkout().ref(ref).branch(branch).execute();
Expand All @@ -97,6 +101,7 @@ public void checkoutBranch(String branch, String ref) throws GitException, Inter
}

/** {@inheritDoc} */
@Deprecated
@Override
public void merge(ObjectId rev) throws GitException, InterruptedException {
merge().setRevisionToMerge(rev).execute();
Expand Down Expand Up @@ -142,21 +147,25 @@ public void setProxy(ProxyConfiguration proxy) {
}

/** {@inheritDoc} */
@Deprecated
@Override
public void submoduleUpdate(boolean recursive) throws GitException, InterruptedException {
submoduleUpdate().recursive(recursive).execute();
}
/** {@inheritDoc} */
@Deprecated
@Override
public void submoduleUpdate(boolean recursive, String reference) throws GitException, InterruptedException {
submoduleUpdate().recursive(recursive).ref(reference).execute();
}
/** {@inheritDoc} */
@Deprecated
@Override
public void submoduleUpdate(boolean recursive, boolean remoteTracking) throws GitException, InterruptedException {
submoduleUpdate().recursive(recursive).remoteTracking(remoteTracking).execute();
}
/** {@inheritDoc} */
@Deprecated
@Override
public void submoduleUpdate(boolean recursive, boolean remoteTracking, String reference)
throws GitException, InterruptedException {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ public FetchCommand tags(boolean tags) {
return this;
}

@Deprecated
@Override
public FetchCommand prune() {
return prune(true);
Expand Down Expand Up @@ -637,12 +638,14 @@ public void execute() throws GitException, InterruptedException {
}

/** {@inheritDoc} */
@Deprecated
@Override
public void fetch(URIish url, List<RefSpec> refspecs) throws GitException, InterruptedException {
fetch_().from(url, refspecs).execute();
}

/** {@inheritDoc} */
@Deprecated
@Override
public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException {
listener.getLogger().println("Fetching upstream changes" + (remoteName != null ? " from " + remoteName : ""));
Expand Down Expand Up @@ -679,6 +682,7 @@ public void fetch(String remoteName, RefSpec... refspec) throws GitException, In
}

/** {@inheritDoc} */
@Deprecated
@Override
public void fetch(String remoteName, RefSpec refspec) throws GitException, InterruptedException {
fetch(remoteName, new RefSpec[] {refspec});
Expand Down Expand Up @@ -733,6 +737,7 @@ public CloneCommand repositoryName(String name) {
return this;
}

@Deprecated
@Override
public CloneCommand shared() {
return shared(true);
Expand All @@ -744,6 +749,7 @@ public CloneCommand shared(boolean shared) {
return this;
}

@Deprecated
@Override
public CloneCommand shallow() {
return shallow(true);
Expand All @@ -755,6 +761,7 @@ public CloneCommand shallow(boolean shallow) {
return this;
}

@Deprecated
@Override
public CloneCommand noCheckout() {
// this.noCheckout = true; Since the "clone" command has been replaced with init + fetch, the
Expand Down Expand Up @@ -2884,6 +2891,7 @@ public PushCommand ref(String refspec) {
return this;
}

@Deprecated
@Override
public PushCommand force() {
return force(true);
Expand Down Expand Up @@ -3361,6 +3369,7 @@ public RevListCommand revList_() {
private String refspec;
private List<ObjectId> out;

@Deprecated
@Override
public RevListCommand all() {
return all(true);
Expand All @@ -3381,6 +3390,7 @@ public RevListCommand nowalk(boolean nowalk) {
return this;
}

@Deprecated
@Override
public RevListCommand firstParent() {
return firstParent(true);
Expand Down Expand Up @@ -3582,6 +3592,7 @@ private void env(String name, String value) {
*/
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "JGit interaction with spotbugs")
@NonNull
@Deprecated
@Override
public Repository getRepository() throws GitException {
try {
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ public org.jenkinsci.plugins.gitclient.FetchCommand from(URIish remote, List<Ref
return this;
}

@Deprecated
@Override
public org.jenkinsci.plugins.gitclient.FetchCommand prune() {
return prune(true);
Expand Down Expand Up @@ -832,14 +833,17 @@ public void execute() throws GitException {
* @param refspecs a {@link java.util.List} object.
* @throws hudson.plugins.git.GitException if any.
* @throws java.lang.InterruptedException if any.
* @deprecated
*/
@Override
@Deprecated
public void fetch(URIish url, List<RefSpec> refspecs) throws GitException, InterruptedException {
fetch_().from(url, refspecs).execute();
}

/** {@inheritDoc} */
@Override
@Deprecated
public void fetch(String remoteName, RefSpec... refspec) throws GitException {
try (Repository repo = getRepository()) {
FetchCommand fetch = git(repo).fetch().setTagOpt(TagOpt.FETCH_TAGS);
Expand All @@ -866,6 +870,7 @@ public void fetch(String remoteName, RefSpec... refspec) throws GitException {

/** {@inheritDoc} */
@Override
@Deprecated
public void fetch(String remoteName, RefSpec refspec) throws GitException {
fetch(remoteName, new RefSpec[] {refspec});
}
Expand All @@ -876,7 +881,7 @@ public void ref(String refName) throws GitException, InterruptedException {
refName = refName.replace(' ', '_');
try (Repository repo = getRepository()) {
RefUpdate refUpdate = repo.updateRef(refName);
refUpdate.setNewObjectId(repo.exactRef(Constants.HEAD).getObjectId());
refUpdate.setNewObjectId(repo.exactRef(HEAD).getObjectId());
switch (refUpdate.forceUpdate()) {
case NOT_ATTEMPTED:
case LOCK_FAILURE:
Expand Down Expand Up @@ -1127,9 +1132,11 @@ public String getRemoteUrl(String name) throws GitException {
*
* @return a {@link org.eclipse.jgit.lib.Repository} object.
* @throws hudson.plugins.git.GitException if underlying git operation fails.
* @deprecated
*/
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "JGit interaction with spotbugs")
@NonNull
@Deprecated
@Override
public Repository getRepository() throws GitException {
try {
Expand Down Expand Up @@ -1541,6 +1548,7 @@ public CloneCommand repositoryName(String name) {
return this;
}

@Deprecated
@Override
public CloneCommand shallow() {
return shallow(true);
Expand All @@ -1552,6 +1560,7 @@ public CloneCommand shallow(boolean shallow) {
return this;
}

@Deprecated
@Override
public CloneCommand shared() {
return shared(true);
Expand Down Expand Up @@ -1587,6 +1596,7 @@ public CloneCommand tags(boolean tags) {
return this;
}

@Deprecated
@Override
public CloneCommand noCheckout() {
// this.noCheckout = true; ignored, we never do a checkout
Expand Down Expand Up @@ -2141,6 +2151,7 @@ public PushCommand ref(String refspec) {
return this;
}

@Deprecated
@Override
public PushCommand force() {
return force(true);
Expand Down Expand Up @@ -2276,6 +2287,7 @@ public RevListCommand revList_() {
private String refspec;
private List<ObjectId> out;

@Deprecated
@Override
public RevListCommand all() {
return all(true);
Expand All @@ -2293,6 +2305,7 @@ public RevListCommand nowalk(boolean nowalk) {
return this;
}

@Deprecated
@Override
public RevListCommand firstParent() {
return firstParent(true);
Expand Down Expand Up @@ -2619,6 +2632,7 @@ public void push(RemoteConfig repository, String refspec) throws GitException, I
}

/** {@inheritDoc} */
@Deprecated
@Override
public List<Branch> getBranchesContaining(String revspec) throws GitException, InterruptedException {
// For the reasons of backward compatibility - we do not query remote branches here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public List<Tag> getTagsOnCommit(String revName) throws GitException, IOExceptio
}

/** {@inheritDoc} */
@Deprecated
@Override
public final List<IndexEntry> lsTree(String treeIsh) throws GitException, InterruptedException {
return lsTree(treeIsh, false);
Expand Down

0 comments on commit ba0ae58

Please sign in to comment.