File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed
src/main/java/org/commonwl/view/git Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 2525import org .eclipse .jgit .api .errors .GitAPIException ;
2626import org .eclipse .jgit .lib .ObjectId ;
2727import org .eclipse .jgit .lib .PersonIdent ;
28- import org .eclipse .jgit .lib .Ref ;
2928import org .eclipse .jgit .revwalk .RevCommit ;
3029import org .slf4j .Logger ;
3130import org .slf4j .LoggerFactory ;
@@ -109,21 +108,13 @@ public Git getRepository(GitDetails gitDetails, boolean reuseDir)
109108 // Checkout the specific branch or commit ID
110109 if (repo != null ) {
111110 // Create a new local branch if it does not exist and not a commit ID
112- boolean createBranch = !ObjectId .isId (gitDetails .getBranch ());
113- if (createBranch ) {
114- Ref ref = repo .getRepository ().exactRef ("refs/heads/" + gitDetails .getBranch ());
115- if (ref != null ) {
116- createBranch = false ;
117- }
111+ String branchOrCommitId = gitDetails .getBranch ();
112+ if (!ObjectId .isId (branchOrCommitId )) {
113+ branchOrCommitId = "refs/remotes/origin/" + branchOrCommitId ;
118114 }
119115 repo .checkout ()
120- .setCreateBranch (createBranch )
121- .setName (gitDetails .getBranch ())
116+ .setName (branchOrCommitId )
122117 .call ();
123- String branch = repo .getRepository ().getFullBranch ();
124- if (branch != null && !branch .startsWith (gitDetails .getBranch ())) {
125- repo .pull ().call ();
126- }
127118 }
128119 } catch (IOException ex ) {
129120 logger .error ("Could not open existing Git repository for '"
You can’t perform that action at this time.
0 commit comments