3
3
4
4
import static org .junit .Assert .assertTrue ;
5
5
6
- import java .io .File ;
7
6
import java .io .IOException ;
8
- import java .io .PrintWriter ;
9
7
import java .util .HashSet ;
10
8
import java .util .Set ;
11
9
@@ -83,7 +81,7 @@ private static String getJvmProperty(String name) {
83
81
84
82
85
83
@ Override
86
- public void setUp () throws IOException {
84
+ public void setUp () throws Exception {
87
85
super .setUp ();
88
86
github = GitHub .connectUsingPassword (GITHUB_USER , GITHUB_PASS );
89
87
gitHubRepo = github .createRepository (repoName )
@@ -104,39 +102,37 @@ public void tearDown() {
104
102
}
105
103
106
104
@ Override
107
- protected void createTestContent (String filePath , String fileContent , String branchName ,
108
- String commitMessage ) throws Exception {
109
- try (IVCSLockedWorkingCopy wc = localVCSRepo .getVCSLockedWorkingCopy ()) {
110
- try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
111
- checkout (branchName , git );
112
-
113
- File file = new File (wc .getFolder (), filePath );
114
- file .getParentFile ().mkdirs ();
115
- file .createNewFile ();
116
- PrintWriter out = new PrintWriter (file );
117
- out .print (fileContent );
118
- out .close ();
119
-
120
- git
121
- .add ()
122
- .addFilepattern (filePath )
123
- .call ();
124
-
125
- git
126
- .commit ()
127
- .setMessage (commitMessage )
128
- .call ();
129
-
130
- RefSpec spec = new RefSpec (branchName + ":" + branchName );
131
- git
132
- .push ()
133
- .setRefSpecs (spec )
134
- .setRemote ("origin" )
135
- .setCredentialsProvider (((GitVCS ) vcs ).getCredentials ())
136
- .call ();
137
-
138
- git .getRepository ().close ();
139
- }
105
+ protected void sendFile (IVCSLockedWorkingCopy wc , String branchName , String filePath , String commitMessage ) throws Exception {
106
+ try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
107
+ checkout (branchName , git );
108
+
109
+ git
110
+ .add ()
111
+ .addFilepattern (filePath )
112
+ .call ();
113
+
114
+ git
115
+ .commit ()
116
+ .setMessage (commitMessage )
117
+ .call ();
118
+
119
+ RefSpec spec = new RefSpec (branchName + ":" + branchName );
120
+ git
121
+ .push ()
122
+ .setRefSpecs (spec )
123
+ .setRemote ("origin" )
124
+ .setCredentialsProvider (((GitVCS ) vcs ).getCredentials ())
125
+ .call ();
126
+
127
+ git .getRepository ().close ();
128
+ }
129
+ }
130
+
131
+ @ Override
132
+ protected void checkout (String branchName , IVCSLockedWorkingCopy wc ) throws Exception {
133
+ try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
134
+ checkout (branchName , git );
135
+ git .getRepository ().close ();
140
136
}
141
137
}
142
138
@@ -206,5 +202,9 @@ protected void setMakeFailureOnVCSReset(Boolean doMakeFailure) {
206
202
mockedGit = null ;
207
203
}
208
204
}
205
+
206
+
207
+
208
+
209
209
}
210
210
0 commit comments