forked from HWKyaraZhou/git-project-KZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitTester.java
More file actions
77 lines (69 loc) · 3.38 KB
/
initTester.java
File metadata and controls
77 lines (69 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import java.io.File;
import java.io.IOException;
public class initTester {
public static void deleteCurrent () {
File gitDirectory = new File ("git");
File objectsDirectory = new File ("git/objects");
String indexFileName = "index";
File indexFile = new File (gitDirectory, indexFileName);
if (gitDirectory.exists() && objectsDirectory.exists() && indexFile.exists()) {
gitDirectory.delete();
System.out.println("Git Directory, Objects Directory, and Index File ALL EXISTED.");
}
else if (gitDirectory.exists() && objectsDirectory.exists() && !indexFile.exists()) {
objectsDirectory.delete();
gitDirectory.delete();
System.out.println("Git Directory, and Objects Directory EXISTED. Index File DID NOT EXIST.");
}
else if (gitDirectory.exists() && !objectsDirectory.exists() && indexFile.exists()) {
gitDirectory.delete();
System.out.println("Git Directory, and Index File EXISTED. Objects Directory DID NOT EXIST.");
}
else if (gitDirectory.exists() && !objectsDirectory.exists() && !indexFile.exists()) {
gitDirectory.delete();
System.out.println("Git Directory EXISTED. Objects Directory and Index File DID NOT EXIST.");
}
else {
System.out.println("Git Directory, Objects Directory, and Index File ALL DID NOT EXIST");
}
}
public static void main (String [] args) throws IOException {
File gitDirectory = new File ("git");
File objectsDirectory = new File ("git/objects");
String indexFileName = "index";
File indexFile = new File (gitDirectory, indexFileName);
Git myGit1 = new Git(false);
System.out.println("Case 1: Has Everything");
System.out.println("Expected Output: Git Directory, Objects Directory, and Index File ALL EXISTED.");
System.out.print("Tester Output: ");
deleteCurrent();
System.out.println("");
System.out.println("Case 2: Has Git Directory with Nothing Inside");
Git myGit2 = new Git(false);
objectsDirectory.delete();
indexFile.delete();
System.out.println("Expected Output: Git Directory EXISTED. Objects Directory and Index File DID NOT EXIST.");
System.out.print("Tester Output: ");
deleteCurrent();
System.out.println("");
System.out.println("Case 3: Has Git Directory with No Objects Directory");
Git myGit3 = new Git(false);
objectsDirectory.delete();
System.out.println("Expected Output: Git Directory, and Index File EXISTED. Objects Directory DID NOT EXIST.");
System.out.print("Tester Output: ");
deleteCurrent();
System.out.println("");
System.out.println("Case 4: Has Git Directory with No Index File");
Git myGit4 = new Git(false);
indexFile.delete();
System.out.println("Expected Output: Git Directory, and Objects Directory EXISTED. Index File DID NOT EXIST.");
System.out.print("Tester Output: ");
deleteCurrent();
System.out.println("");
System.out.println("Case 5: Has Nothing");
System.out.println("Expected Output: Git Directory, Objects Directory, and Index File ALL DID NOT EXIST");
System.out.print("Tester Output: ");
deleteCurrent();
System.out.println("");
}
}