File tree 1 file changed +4
-13
lines changed
src/main/java/org/commonwl/view/git
1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 25
25
import org .eclipse .jgit .api .errors .GitAPIException ;
26
26
import org .eclipse .jgit .lib .ObjectId ;
27
27
import org .eclipse .jgit .lib .PersonIdent ;
28
- import org .eclipse .jgit .lib .Ref ;
29
28
import org .eclipse .jgit .revwalk .RevCommit ;
30
29
import org .slf4j .Logger ;
31
30
import org .slf4j .LoggerFactory ;
@@ -109,21 +108,13 @@ public Git getRepository(GitDetails gitDetails, boolean reuseDir)
109
108
// Checkout the specific branch or commit ID
110
109
if (repo != null ) {
111
110
// 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 ;
118
114
}
119
115
repo .checkout ()
120
- .setCreateBranch (createBranch )
121
- .setName (gitDetails .getBranch ())
116
+ .setName (branchOrCommitId )
122
117
.call ();
123
- String branch = repo .getRepository ().getFullBranch ();
124
- if (branch != null && !branch .startsWith (gitDetails .getBranch ())) {
125
- repo .pull ().call ();
126
- }
127
118
}
128
119
} catch (IOException ex ) {
129
120
logger .error ("Could not open existing Git repository for '"
You can’t perform that action at this time.
0 commit comments