Skip to content

Commit 6e501b9

Browse files
authored
Cleanup deprecated/unused code (#898)
1 parent 2e79bb3 commit 6e501b9

8 files changed

+2
-209
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package com.cloudbees.jenkins.plugins.bitbucket;
2525

2626
import com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.DescriptorImpl;
27-
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator;
2827
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketHref;
2928
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
3029
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol;
@@ -42,6 +41,7 @@
4241
import hudson.plugins.git.browser.BitbucketWeb;
4342
import java.util.List;
4443
import jenkins.plugins.git.GitSCMBuilder;
44+
import jenkins.plugins.git.MergeWithGitSCMExtension;
4545
import jenkins.scm.api.SCMHead;
4646
import jenkins.scm.api.SCMRevision;
4747
import jenkins.scm.api.SCMSource;
@@ -311,13 +311,6 @@ private String getCloneLink(List<BitbucketHref> cloneLinks) {
311311
return cloneLinks.stream()
312312
.filter(link -> protocol.matches(link.getName()))
313313
.findAny()
314-
.map(bitbucketHref -> {
315-
BitbucketAuthenticator authenticator = scmSource().authenticator();
316-
if (authenticator == null) {
317-
return bitbucketHref;
318-
}
319-
return authenticator.addAuthToken(bitbucketHref);
320-
})
321314
.orElseThrow(() -> new IllegalStateException("Can't find clone link for protocol " + protocol))
322315
.getHref();
323316
}

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketMirroredRepositoryDescriptor;
3535
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPullRequest;
3636
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
37-
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
3837
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException;
3938
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketTeam;
4039
import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient;
@@ -117,7 +116,6 @@
117116
import jenkins.scm.impl.trait.Selection;
118117
import jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait;
119118
import org.apache.commons.lang.StringUtils;
120-
import org.apache.commons.lang.WordUtils;
121119
import org.eclipse.jgit.lib.Constants;
122120
import org.jenkinsci.Symbol;
123121
import org.kohsuke.accmod.Restricted;
@@ -230,12 +228,6 @@ public class BitbucketSCMSource extends SCMSource {
230228
@RestrictedSince("2.2.0")
231229
private transient String bitbucketServerUrl;
232230

233-
/**
234-
* The cache of the repository type.
235-
*/
236-
@CheckForNull
237-
private transient BitbucketRepositoryType repositoryType;
238-
239231
/**
240232
* The cache of pull request titles for each open PR.
241233
*/
@@ -296,7 +288,6 @@ public BitbucketSCMSource(@CheckForNull String id, @NonNull String repoOwner, @N
296288
* @return {@code this}
297289
* @throws ObjectStreamException if things go wrong.
298290
*/
299-
@SuppressWarnings({"ConstantConditions", "deprecation"})
300291
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
301292
justification = "Only non-null after we set them here!")
302293
private Object readResolve() throws ObjectStreamException {
@@ -529,18 +520,6 @@ public boolean isAutoRegisterHook() {
529520
return true;
530521
}
531522

532-
public BitbucketRepositoryType getRepositoryType() throws IOException, InterruptedException {
533-
if (repositoryType == null) {
534-
BitbucketRepository r = buildBitbucketClient().getRepository();
535-
repositoryType = BitbucketRepositoryType.fromString(r.getScm());
536-
Map<String, List<BitbucketHref>> links = r.getLinks();
537-
if (links != null && links.containsKey("clone")) {
538-
setPrimaryCloneLinks(links.get("clone"));
539-
}
540-
}
541-
return repositoryType;
542-
}
543-
544523
public BitbucketApi buildBitbucketClient() {
545524
return buildBitbucketClient(repoOwner, repository);
546525
}
@@ -553,17 +532,6 @@ public BitbucketApi buildBitbucketClient(String repoOwner, String repository) {
553532
return BitbucketApiFactory.newInstance(getServerUrl(), authenticator(), repoOwner, null, repository);
554533
}
555534

556-
@Override
557-
public void afterSave() {
558-
try {
559-
getRepositoryType();
560-
} catch (InterruptedException | IOException e) {
561-
LOGGER.log(Level.FINE,
562-
"Could not determine repository type of " + getRepoOwner() + "/" + getRepository() + " on "
563-
+ getServerUrl() + " for " + getOwner(), e);
564-
}
565-
}
566-
567535
@Override
568536
protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHeadObserver observer,
569537
@CheckForNull SCMHeadEvent<?> event, @NonNull TaskListener listener)
@@ -578,9 +546,6 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHe
578546
listener.getLogger().format("Connecting to %s using %s%n", getServerUrl(),
579547
CredentialsNameProvider.name(scanCredentials));
580548
}
581-
// this has the side effect of ensuring that repository type is always populated.
582-
final BitbucketRepositoryType repositoryType = getRepositoryType();
583-
listener.getLogger().format("Repository type: %s%n", WordUtils.capitalizeFully(repositoryType != null ? repositoryType.name() : "Unknown"));
584549

585550
// populate the request with its data sources
586551
if (request.isFetchPRs()) {

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketTagSCMHead.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
*/
2424
package com.cloudbees.jenkins.plugins.bitbucket;
2525

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

4038
private static final long serialVersionUID = 1L;
4139

42-
/**
43-
* Cache of the repository type.
44-
*
45-
* @since 2.2.11
46-
*/
47-
// The repository type should be immutable for any SCMSource.
48-
@CheckForNull
49-
private final BitbucketRepositoryType repositoryType;
50-
5140
/**
5241
* Constructor.
5342
*
@@ -56,16 +45,6 @@ public class BitbucketTagSCMHead extends GitTagSCMHead implements TagSCMHead {
5645
*/
5746
public BitbucketTagSCMHead(@NonNull String tagName, long timestamp) {
5847
super(tagName, timestamp);
59-
this.repositoryType = BitbucketRepositoryType.GIT;
60-
}
61-
62-
/**
63-
* Gets the repository type.
64-
* @return the repository type or {@code null}
65-
*/
66-
@CheckForNull
67-
public BitbucketRepositoryType getRepositoryType() {
68-
return repositoryType;
6948
}
7049

7150
/**

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BranchSCMHead.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
*/
2424
package com.cloudbees.jenkins.plugins.bitbucket;
2525

26-
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
27-
import edu.umd.cs.findbugs.annotations.CheckForNull;
2826
import jenkins.scm.api.SCMHead;
2927

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

3735
private static final long serialVersionUID = 1L;
3836

39-
/**
40-
* Cache of the repository type. Will only be {@code null} for data loaded from pre-2.1.0 releases
41-
*
42-
* @since 2.1.0
43-
*/
44-
// The repository type should be immutable for any SCMSource.
45-
@CheckForNull
46-
private final BitbucketRepositoryType repositoryType;
47-
4837
/**
4938
* Constructor.
5039
*
5140
* @param branchName the branch name
5241
*/
5342
public BranchSCMHead(String branchName) {
5443
super(branchName);
55-
this.repositoryType = BitbucketRepositoryType.GIT;
56-
}
57-
58-
/**
59-
* Gets the repository type.
60-
* @return the repository type or {@code null} if this is a legacy branch instance.
61-
*/
62-
@CheckForNull
63-
public BitbucketRepositoryType getRepositoryType() {
64-
return repositoryType;
6544
}
6645

6746
/**

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/MergeWithGitSCMExtension.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMHead.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package com.cloudbees.jenkins.plugins.bitbucket;
2525

2626
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPullRequest;
27-
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryType;
2827
import edu.umd.cs.findbugs.annotations.NonNull;
2928
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3029
import hudson.Extension;
@@ -165,10 +164,6 @@ public String getBranchName() {
165164
return branchName;
166165
}
167166

168-
public BitbucketRepositoryType getRepositoryType() {
169-
return target.getRepositoryType();
170-
}
171-
172167
@NonNull
173168
@Override
174169
public String getId() {

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticator.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public abstract class BitbucketAuthenticator {
7070
*
7171
* @param credentials credentials instance this authenticator will use
7272
*/
73-
public BitbucketAuthenticator(StandardCredentials credentials) {
73+
protected BitbucketAuthenticator(StandardCredentials credentials) {
7474
id = credentials.getId();
7575
}
7676

@@ -118,16 +118,6 @@ public StandardUsernameCredentials getCredentialsForScm() {
118118
return null;
119119
}
120120

121-
/**
122-
* Add authentication token to clone link if
123-
* authentication method requires it
124-
*
125-
* @return updated clone link
126-
*/
127-
public BitbucketHref addAuthToken(BitbucketHref bitbucketHref) {
128-
return bitbucketHref;
129-
}
130-
131121
/**
132122
* Generates context that sub-classes can use to determine if they would be able to authenticate against the
133123
* provided server.

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketRepositoryType.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)