-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommit.java
More file actions
25 lines (21 loc) · 787 Bytes
/
Commit.java
File metadata and controls
25 lines (21 loc) · 787 Bytes
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
import java.io.File;
import java.util.Date;
import java.util.Scanner;
public class Commit extends KeyValue{
public static File config = new File(gitFolder,"config");
public Commit(String message) throws Exception {
value = genValue(message);
key = "C" + genKey();
Head.update(key);
setKVfile();
}
public byte[] genValue(String message) throws Exception {
String rootTreeKey = new Tree(path).key;
String parentCommitKey = Head.getCommitKey();
String time = new Date().toString();
String author = new Scanner(config).nextLine();
String result = rootTreeKey + "\n" + parentCommitKey + "\n";
result += message + "\n" + time + "\n" + author;
return result.getBytes();
}
}