@@ -108,8 +108,7 @@ private void checkCurrentVersion(File root, int timestamp, String commitId, Stri
108
108
}
109
109
110
110
@ Test
111
- public void testDetermineCurrentVersion () throws Exception {
112
- // First test with empty repository.
111
+ public void testDetermineCurrentVersionWithEmptyRepository () throws Exception {
113
112
File emptyGitDir = new File (repository .getSourceRoot (), "gitEmpty" );
114
113
try (Git git = Git .init ().setDirectory (emptyGitDir ).call ()) {
115
114
GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (git .getRepository ().getWorkTree ());
@@ -118,16 +117,25 @@ public void testDetermineCurrentVersion() throws Exception {
118
117
assertNull (ver );
119
118
FileUtilities .removeDirs (emptyGitDir );
120
119
}
120
+ }
121
121
122
- // Next, check known repository with some commits.
122
+ @ Test
123
+ public void testDetermineCurrentVersionOfKnownRepository () throws Exception {
123
124
File root = new File (repository .getSourceRoot (), "git" );
124
125
GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
125
126
assertNotNull (gitrepo );
126
127
String ver = gitrepo .determineCurrentVersion ();
127
128
assertNotNull (ver );
128
129
Date date = new Date ((long ) (1485438707 ) * 1000 );
129
130
assertEquals (Repository .format (date ) + " 84599b3 Kryštof Tulinger renaming directories" , ver );
131
+ }
130
132
133
+ @ Test
134
+ public void testDetermineCurrentVersionAfterChange () throws Exception {
135
+ File root = new File (repository .getSourceRoot (), "git" );
136
+ GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
137
+ assertNotNull (gitrepo );
138
+ String ver ;
131
139
// Clone under source root to avoid problems with prohibited symlinks.
132
140
File localPath = new File (repository .getSourceRoot (), "gitCloneTestCurrentVersion" );
133
141
String cloneUrl = root .toURI ().toString ();
@@ -167,17 +175,23 @@ public void testDetermineCurrentVersion() throws Exception {
167
175
}
168
176
169
177
@ Test
170
- public void testDetermineBranch () throws Exception {
178
+ public void testDetermineBranchBasic () throws Exception {
171
179
// First check branch of known repository.
172
180
File root = new File (repository .getSourceRoot (), "git" );
173
181
GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
174
182
String branch = gitrepo .determineBranch ();
175
183
Assert .assertNotNull (branch );
176
184
assertEquals ("master" , branch );
185
+ }
177
186
178
- // Next, clone the repository and create new branch there.
187
+ @ Test
188
+ public void testDetermineBranchAfterChange () throws Exception {
189
+ // Clone the test repository and create new branch there.
179
190
// Clone under source root to avoid problems with prohibited symlinks.
191
+ File root = new File (repository .getSourceRoot (), "git" );
180
192
File localPath = new File (repository .getSourceRoot (), "gitCloneTestDetermineBranch" );
193
+ GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
194
+ String branch ;
181
195
String cloneUrl = root .toURI ().toString ();
182
196
try (Git gitClone = Git .cloneRepository ()
183
197
.setURI (cloneUrl )
@@ -198,13 +212,19 @@ public void testDetermineBranch() throws Exception {
198
212
}
199
213
200
214
@ Test
201
- public void testDetermineParent () throws Exception {
215
+ public void testDetermineParentEmpty () throws Exception {
202
216
File root = new File (repository .getSourceRoot (), "git" );
203
217
GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
204
218
String parent = gitrepo .determineParent ();
205
219
Assert .assertNull (parent );
220
+ }
206
221
207
- // Next, clone the repository and create new origin there.
222
+ @ Test
223
+ public void testDetermineParent () throws Exception {
224
+ File root = new File (repository .getSourceRoot (), "git" );
225
+ GitRepository gitrepo = (GitRepository ) RepositoryFactory .getRepository (root );
226
+ String parent ;
227
+ // Clone the repository and create new origin there.
208
228
// Clone under source root to avoid problems with prohibited symlinks.
209
229
File localPath = new File (repository .getSourceRoot (), "gitCloneTestDetermineParent" );
210
230
String cloneUrl = root .toURI ().toString ();
0 commit comments