Skip to content

Commit

Permalink
Cleanup deprecated/unused code (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfalco79 authored Nov 3, 2024
1 parent 2e79bb3 commit 6e501b9
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.cloudbees.jenkins.plugins.bitbucket;

import com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.DescriptorImpl;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketHref;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol;
Expand All @@ -42,6 +41,7 @@
import hudson.plugins.git.browser.BitbucketWeb;
import java.util.List;
import jenkins.plugins.git.GitSCMBuilder;
import jenkins.plugins.git.MergeWithGitSCMExtension;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
Expand Down Expand Up @@ -311,13 +311,6 @@ private String getCloneLink(List<BitbucketHref> cloneLinks) {
return cloneLinks.stream()
.filter(link -> protocol.matches(link.getName()))
.findAny()
.map(bitbucketHref -> {
BitbucketAuthenticator authenticator = scmSource().authenticator();
if (authenticator == null) {
return bitbucketHref;
}
return authenticator.addAuthToken(bitbucketHref);
})
.orElseThrow(() -> new IllegalStateException("Can't find clone link for protocol " + protocol))
.getHref();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketMirroredRepositoryDescriptor;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPullRequest;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketTeam;
import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient;
Expand Down Expand Up @@ -117,7 +116,6 @@
import jenkins.scm.impl.trait.Selection;
import jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import org.eclipse.jgit.lib.Constants;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
Expand Down Expand Up @@ -230,12 +228,6 @@ public class BitbucketSCMSource extends SCMSource {
@RestrictedSince("2.2.0")
private transient String bitbucketServerUrl;

/**
* The cache of the repository type.
*/
@CheckForNull
private transient BitbucketRepositoryType repositoryType;

/**
* The cache of pull request titles for each open PR.
*/
Expand Down Expand Up @@ -296,7 +288,6 @@ public BitbucketSCMSource(@CheckForNull String id, @NonNull String repoOwner, @N
* @return {@code this}
* @throws ObjectStreamException if things go wrong.
*/
@SuppressWarnings({"ConstantConditions", "deprecation"})
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
justification = "Only non-null after we set them here!")
private Object readResolve() throws ObjectStreamException {
Expand Down Expand Up @@ -529,18 +520,6 @@ public boolean isAutoRegisterHook() {
return true;
}

public BitbucketRepositoryType getRepositoryType() throws IOException, InterruptedException {
if (repositoryType == null) {
BitbucketRepository r = buildBitbucketClient().getRepository();
repositoryType = BitbucketRepositoryType.fromString(r.getScm());
Map<String, List<BitbucketHref>> links = r.getLinks();
if (links != null && links.containsKey("clone")) {
setPrimaryCloneLinks(links.get("clone"));
}
}
return repositoryType;
}

public BitbucketApi buildBitbucketClient() {
return buildBitbucketClient(repoOwner, repository);
}
Expand All @@ -553,17 +532,6 @@ public BitbucketApi buildBitbucketClient(String repoOwner, String repository) {
return BitbucketApiFactory.newInstance(getServerUrl(), authenticator(), repoOwner, null, repository);
}

@Override
public void afterSave() {
try {
getRepositoryType();
} catch (InterruptedException | IOException e) {
LOGGER.log(Level.FINE,
"Could not determine repository type of " + getRepoOwner() + "/" + getRepository() + " on "
+ getServerUrl() + " for " + getOwner(), e);
}
}

@Override
protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHeadObserver observer,
@CheckForNull SCMHeadEvent<?> event, @NonNull TaskListener listener)
Expand All @@ -578,9 +546,6 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHe
listener.getLogger().format("Connecting to %s using %s%n", getServerUrl(),
CredentialsNameProvider.name(scanCredentials));
}
// this has the side effect of ensuring that repository type is always populated.
final BitbucketRepositoryType repositoryType = getRepositoryType();
listener.getLogger().format("Repository type: %s%n", WordUtils.capitalizeFully(repositoryType != null ? repositoryType.name() : "Unknown"));

// populate the request with its data sources
if (request.isFetchPRs()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
package com.cloudbees.jenkins.plugins.bitbucket;

import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.plugins.git.GitTagSCMHead;
import jenkins.scm.api.SCMHead;
Expand All @@ -39,15 +37,6 @@ public class BitbucketTagSCMHead extends GitTagSCMHead implements TagSCMHead {

private static final long serialVersionUID = 1L;

/**
* Cache of the repository type.
*
* @since 2.2.11
*/
// The repository type should be immutable for any SCMSource.
@CheckForNull
private final BitbucketRepositoryType repositoryType;

/**
* Constructor.
*
Expand All @@ -56,16 +45,6 @@ public class BitbucketTagSCMHead extends GitTagSCMHead implements TagSCMHead {
*/
public BitbucketTagSCMHead(@NonNull String tagName, long timestamp) {
super(tagName, timestamp);
this.repositoryType = BitbucketRepositoryType.GIT;
}

/**
* Gets the repository type.
* @return the repository type or {@code null}
*/
@CheckForNull
public BitbucketRepositoryType getRepositoryType() {
return repositoryType;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
package com.cloudbees.jenkins.plugins.bitbucket;

import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import jenkins.scm.api.SCMHead;

/**
Expand All @@ -36,32 +34,13 @@ public class BranchSCMHead extends SCMHead {

private static final long serialVersionUID = 1L;

/**
* Cache of the repository type. Will only be {@code null} for data loaded from pre-2.1.0 releases
*
* @since 2.1.0
*/
// The repository type should be immutable for any SCMSource.
@CheckForNull
private final BitbucketRepositoryType repositoryType;

/**
* Constructor.
*
* @param branchName the branch name
*/
public BranchSCMHead(String branchName) {
super(branchName);
this.repositoryType = BitbucketRepositoryType.GIT;
}

/**
* Gets the repository type.
* @return the repository type or {@code null} if this is a legacy branch instance.
*/
@CheckForNull
public BitbucketRepositoryType getRepositoryType() {
return repositoryType;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.cloudbees.jenkins.plugins.bitbucket;

import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPullRequest;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
Expand Down Expand Up @@ -165,10 +164,6 @@ public String getBranchName() {
return branchName;
}

public BitbucketRepositoryType getRepositoryType() {
return target.getRepositoryType();
}

@NonNull
@Override
public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public abstract class BitbucketAuthenticator {
*
* @param credentials credentials instance this authenticator will use
*/
public BitbucketAuthenticator(StandardCredentials credentials) {
protected BitbucketAuthenticator(StandardCredentials credentials) {
id = credentials.getId();
}

Expand Down Expand Up @@ -118,16 +118,6 @@ public StandardUsernameCredentials getCredentialsForScm() {
return null;
}

/**
* Add authentication token to clone link if
* authentication method requires it
*
* @return updated clone link
*/
public BitbucketHref addAuthToken(BitbucketHref bitbucketHref) {
return bitbucketHref;
}

/**
* Generates context that sub-classes can use to determine if they would be able to authenticate against the
* provided server.
Expand Down

This file was deleted.

0 comments on commit 6e501b9

Please sign in to comment.