Skip to content

Commit

Permalink
update commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ffanyt authored Jan 27, 2023
1 parent 4123e22 commit 717e994
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proj2/gitlet/Commit.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public Commit(String ms) {
blobNode = updateBlob(parentBlob);
hashCode = calHash();
}
public Commit(String ms, List parent) {
message = ms;
Date time = new Date();
timestamp = caltimestamp(time);
parentNoed = parent;
HashMap parentBlob = readParentBlob();
blobNode = updateBlob(parentBlob);
hashCode = calHash();
}
public void save() {
File currentCommitFile = join(Repository.COMMIT_DIR, this.hashCode);
writeObject(currentCommitFile, this);
Expand Down Expand Up @@ -86,6 +95,8 @@ private HashMap updateBlob(HashMap parent) {
newBlob.save();
newMap.put(stageFILENAME, newBlob.getHashCode());
}
File stageFile = join(Repository.STAGE_DIR, stageFILENAME);
stageFile.delete();
}

List removeStageList = plainFilenamesIn(Repository.REMOVEL_DIR);
Expand Down

0 comments on commit 717e994

Please sign in to comment.