24
24
import org .scm4j .vcs .api .exceptions .*;
25
25
import org .scm4j .vcs .api .workingcopy .IVCSLockedWorkingCopy ;
26
26
import org .scm4j .vcs .api .workingcopy .IVCSRepositoryWorkspace ;
27
- import org .scm4j .vcs .api .workingcopy .IVCSWorkspace ;
28
27
29
28
import java .io .*;
30
29
import java .net .*;
@@ -143,7 +142,7 @@ public void createBranch(String srcBranchName, String newBranchName, String comm
143
142
144
143
push (git , refSpec );
145
144
} catch (RefAlreadyExistsException e ) {
146
- throw new EVCSBranchExists ( e );
145
+ throw new EVCSBranchExists ( newBranchName );
147
146
} catch (GitAPIException e ) {
148
147
throw new EVCSException (e );
149
148
} catch (Exception e ) {
@@ -176,7 +175,7 @@ public void deleteBranch(String branchName, String commitMessage) {
176
175
}
177
176
178
177
private void push (Git git , RefSpec refSpec ) throws GitAPIException {
179
- PushCommand cmd = git
178
+ PushCommand cmd = git
180
179
.push ();
181
180
if (refSpec != null ) {
182
181
cmd .setRefSpecs (refSpec );
@@ -295,7 +294,7 @@ public String getFileContent(String branchName, String fileRelativePath, String
295
294
.setCredentialsProvider (credentials )
296
295
.call ();
297
296
298
- ObjectId revisionCommitId = gitRepo .resolve (revision == null ? "refs/heads/" + getRealBranchName (branchName ) : revision );
297
+ ObjectId revisionCommitId = gitRepo .resolve (revision == null ? "refs/heads/" + getRealBranchName (branchName ) : revision );
299
298
if (revision == null && revisionCommitId == null ) {
300
299
throw new EVCSBranchNotFound (getRepoUrl (), getRealBranchName (branchName ));
301
300
}
@@ -313,7 +312,9 @@ public String getFileContent(String branchName, String fileRelativePath, String
313
312
ObjectLoader loader = gitRepo .open (objectId );
314
313
InputStream in = loader .openStream ();
315
314
String res = IOUtils .toString (in , StandardCharsets .UTF_8 );
315
+
316
316
if (revision != null ) {
317
+ // need to prevent "checkout conflict with files" exception on scm4j-releaser testTagExistsOnExecute() test
317
318
git
318
319
.reset ()
319
320
.setMode (ResetType .HARD )
@@ -496,10 +497,10 @@ public List<VCSCommit> log(String branchName, int limit) {
496
497
log .setMaxCount (limit );
497
498
}
498
499
499
- Iterable <RevCommit > logs = log .call ();
500
+ Iterable <RevCommit > commits = log .call ();
500
501
501
502
List <VCSCommit > res = new ArrayList <>();
502
- for (RevCommit commit : logs ) {
503
+ for (RevCommit commit : commits ) {
503
504
res .add (getVCSCommit (commit ));
504
505
}
505
506
@@ -549,7 +550,7 @@ private VCSCommit getVCSCommit(RevCommit revCommit) {
549
550
return new VCSCommit (revCommit .getName (), revCommit .getFullMessage (), revCommit .getAuthorIdent ().getName ());
550
551
}
551
552
552
- public List <VCSCommit > getCommitsRange (String branchName , String afterCommitId , String untilCommitId ) {
553
+ public List <VCSCommit > getCommitsRange (String branchName , String startRevision , String endRevision ) {
553
554
try (IVCSLockedWorkingCopy wc = repo .getVCSLockedWorkingCopy ();
554
555
Git git = getLocalGit (wc );
555
556
Repository gitRepo = git .getRepository ()) {
@@ -558,18 +559,18 @@ public List<VCSCommit> getCommitsRange(String branchName, String afterCommitId,
558
559
559
560
String bn = getRealBranchName (branchName );
560
561
561
- ObjectId sinceCommit = afterCommitId == null ?
562
+ ObjectId startCommit = startRevision == null ?
562
563
getInitialCommit (gitRepo , bn ).getId () :
563
- ObjectId .fromString (afterCommitId );
564
+ ObjectId .fromString (startRevision );
564
565
565
- ObjectId untilCommit = untilCommitId == null ?
566
+ ObjectId endCommit = endRevision == null ?
566
567
gitRepo .exactRef ("refs/heads/" + bn ).getObjectId () :
567
- ObjectId .fromString (untilCommitId );
568
+ ObjectId .fromString (endRevision );
568
569
569
570
Iterable <RevCommit > commits ;
570
571
commits = git
571
572
.log ()
572
- .addRange (sinceCommit , untilCommit )
573
+ .addRange (startCommit , endCommit )
573
574
.call ();
574
575
575
576
List <VCSCommit > res = new ArrayList <>();
@@ -599,13 +600,8 @@ private RevCommit getInitialCommit(Repository gitRepo, String branchName) throws
599
600
}
600
601
601
602
@ Override
602
- public IVCSWorkspace getWorkspace () {
603
- return repo .getWorkspace ();
604
- }
605
-
606
- @ Override
607
- public List <VCSCommit > getCommitsRange (String branchName , String startFromCommitId , WalkDirection direction ,
608
- int limit ) {
603
+ public List <VCSCommit > getCommitsRange (String branchName , String startRevision , WalkDirection direction ,
604
+ int limit ) {
609
605
try (IVCSLockedWorkingCopy wc = repo .getVCSLockedWorkingCopy ();
610
606
Git git = getLocalGit (wc );
611
607
Repository gitRepo = git .getRepository ();
@@ -620,15 +616,15 @@ public List<VCSCommit> getCommitsRange(String branchName, String startFromCommit
620
616
if (direction == WalkDirection .ASC ) {
621
617
ObjectId headCommitId = gitRepo .exactRef ("refs/remotes/origin/" + bn ).getObjectId ();
622
618
startCommit = rw .parseCommit ( headCommitId );
623
- ObjectId sinceCommit = startFromCommitId == null ?
619
+ ObjectId startCommitObjectId = startRevision == null ?
624
620
getInitialCommit (gitRepo , bn ).getId () :
625
- ObjectId .fromString (startFromCommitId );
626
- endCommit = rw .parseCommit (sinceCommit );
621
+ ObjectId .fromString (startRevision );
622
+ endCommit = rw .parseCommit (startCommitObjectId );
627
623
} else {
628
- ObjectId sinceCommit = startFromCommitId == null ?
624
+ ObjectId endCommitObjectId = startRevision == null ?
629
625
gitRepo .exactRef ("refs/remotes/origin/" + bn ).getObjectId () :
630
- ObjectId .fromString (startFromCommitId );
631
- startCommit = rw .parseCommit ( sinceCommit );
626
+ ObjectId .fromString (startRevision );
627
+ startCommit = rw .parseCommit ( endCommitObjectId );
632
628
endCommit = getInitialCommit (gitRepo , bn );
633
629
}
634
630
0 commit comments