@@ -64,17 +64,17 @@ private String getRealBranchName(String branchName) {
64
64
return branchName == null ? MASTER_BRANCH_NAME : branchName ;
65
65
}
66
66
67
- public Git getLocalGit (IVCSLockedWorkingCopy wc ) throws Exception {
67
+ protected Git getLocalGit (String folder ) throws Exception {
68
68
Repository gitRepo = new FileRepositoryBuilder ()
69
- .setGitDir (new File (wc . getFolder () , ".git" ))
69
+ .setGitDir (new File (folder , ".git" ))
70
70
.build ();
71
71
Boolean repoInited = gitRepo
72
72
.getObjectDatabase ()
73
73
.exists ();
74
74
if (!repoInited ) {
75
75
Git
76
76
.cloneRepository ()
77
- .setDirectory (wc . getFolder ( ))
77
+ .setDirectory (new File ( folder ))
78
78
.setURI (repo .getRepoUrl ())
79
79
.setCredentialsProvider (credentials )
80
80
.setNoCheckout (true )
@@ -85,6 +85,10 @@ public Git getLocalGit(IVCSLockedWorkingCopy wc) throws Exception {
85
85
return new Git (gitRepo );
86
86
}
87
87
88
+ protected Git getLocalGit (IVCSLockedWorkingCopy wc ) throws Exception {
89
+ return getLocalGit (wc .getFolder ().getPath ());
90
+ }
91
+
88
92
public VCSChangeType gitChangeTypeToVCSChangeType (ChangeType changeType ) {
89
93
switch (changeType ) {
90
94
case ADD :
@@ -765,6 +769,20 @@ public void removeTag(String tagName) {
765
769
throw new EVCSException (e );
766
770
} catch (Exception e ) {
767
771
throw new RuntimeException (e );
768
- }
772
+ }
773
+ }
774
+
775
+ @ Override
776
+ public void checkout (String branchName , String targetPath ) {
777
+ try (Git git = getLocalGit (targetPath );
778
+ Repository gitRepo = git .getRepository ()) {
779
+
780
+ checkout (git , gitRepo , branchName );
781
+
782
+ } catch (GitAPIException e ) {
783
+ throw new EVCSException (e );
784
+ } catch (Exception e ) {
785
+ throw new RuntimeException (e );
786
+ }
769
787
}
770
788
}
0 commit comments