Skip to content

Commit 9377a7e

Browse files
committed
EVCSBranchNotFound.java if moved to scm4j-vcs-api
fixed missing credentials provider setting in various places
1 parent f763ec7 commit 9377a7e

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

src/main/java/org/scm4j/vcs/EVCSBranchNotFound.java

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

src/main/java/org/scm4j/vcs/GitVCS.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.jgit.treewalk.filter.PathFilter;
2323
import org.scm4j.vcs.api.*;
2424
import org.scm4j.vcs.api.exceptions.EVCSBranchExists;
25+
import org.scm4j.vcs.api.exceptions.EVCSBranchNotFound;
2526
import org.scm4j.vcs.api.exceptions.EVCSException;
2627
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
2728
import org.scm4j.vcs.api.exceptions.EVCSTagExists;
@@ -105,6 +106,7 @@ public VCSTag createUnannotatedTag(String branchName, String tagName, String rev
105106

106107
git
107108
.pull()
109+
.setCredentialsProvider(credentials)
108110
.call();
109111

110112
RevCommit commitToTag = revisionToTag == null ? null : rw.parseCommit(ObjectId.fromString(revisionToTag));
@@ -294,10 +296,13 @@ public String getFileContent(String branchName, String fileRelativePath, String
294296
git
295297
.fetch()
296298
.setRefSpecs(new RefSpec("+refs/heads/*:refs/heads/*"))
297-
//.setRemoveDeletedRefs(true)
298299
.setCredentialsProvider(credentials)
299300
.call();
300-
git.pull().call(); //TODO: add test when we receive correct file version if we change it from another LWC
301+
git
302+
.pull()
303+
.setCredentialsProvider(credentials)
304+
.call(); //TODO: add test when we receive correct file version if we change it from another LWC
305+
301306
ObjectId revisionCommitId = gitRepo.resolve(revision == null ? "refs/heads/" + getRealBranchName(branchName) : revision);
302307
if (revision == null && revisionCommitId == null) {
303308
throw new EVCSBranchNotFound(getRepoUrl(), getRealBranchName(branchName));
@@ -371,6 +376,7 @@ void checkout(Git git, Repository gitRepo, String branchName, String revision) t
371376
if (revision == null) {
372377
git
373378
.pull()
379+
.setCredentialsProvider(credentials)
374380
.call();
375381
cmd
376382
.setStartPoint("origin/" + bn)
@@ -449,7 +455,11 @@ public Set<String> getBranches(String path) {
449455
Git git = getLocalGit(wc);
450456
Repository gitRepo = git.getRepository()) {
451457

452-
git.pull().call(); //TODO: add test when we receive correct branches list if we change it from another LWC
458+
git
459+
.pull()
460+
.setCredentialsProvider(credentials)
461+
.call(); //TODO: add test when we receive correct branches list if we change it from another LWC
462+
453463
Collection<Ref> refs = gitRepo.getRefDatabase().getRefs(REFS_REMOTES_ORIGIN).values();
454464
Set<String> res = new HashSet<>();
455465
String bn;
@@ -739,6 +749,7 @@ private void updateLocalTags(Git git) throws Exception {
739749
.call();
740750
git
741751
.pull()
752+
.setCredentialsProvider(credentials)
742753
.call();
743754
}
744755

@@ -774,19 +785,6 @@ public List<VCSTag> getTags() {
774785
}
775786
}
776787

777-
// private List<Ref> getTagRefs(Git git) throws Exception {
778-
// // need to remove tags from local repo which are removed in origin
779-
// git
780-
// .fetch()
781-
// .setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"))
782-
// .setRemoveDeletedRefs(true)
783-
// .setCredentialsProvider(credentials)
784-
// .call();
785-
// return git
786-
// .tagList()
787-
// .call();
788-
// }
789-
790788
@Override
791789
public void removeTag(String tagName) {
792790
try (IVCSLockedWorkingCopy wc = repo.getVCSLockedWorkingCopy();

0 commit comments

Comments
 (0)