-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGitRepositoryInitializer.java
More file actions
44 lines (40 loc) · 1.12 KB
/
GitRepositoryInitializer.java
File metadata and controls
44 lines (40 loc) · 1.12 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
import java.io.File;
import java.io.IOException;
public class GitRepositoryInitializer {
public static void initGitRepo() {
boolean created = false;
File git = new File("git");
if (!git.exists()) {
git.mkdir();
created = true;
}
File objects = new File(git, "objects");
if (!objects.exists()) {
objects.mkdir();
created = true;
}
File index = new File(git, "index");
if (!index.exists()) {
try {
index.createNewFile();
created = true;
} catch (IOException e) {
System.out.println(e);
}
}
File HEAD = new File(git, "HEAD");
if (!HEAD.exists()) {
try {
HEAD.createNewFile();
created = true;
} catch (IOException e) {
System.out.println(e);
}
}
if (created) {
System.out.println("Git Repository Created");
} else {
System.out.println("Git Repository Already Exists");
}
}
}