-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This makefile is defined to give you the following targets: | ||
# | ||
# default: The default target: Compiles the program in package db61b. | ||
# check: Compiles the gitlet package, if needed, and then performs the | ||
# tests described in testing/Makefile. | ||
# clean: Remove regeneratable files (such as .class files) produced by | ||
# other targets and Emacs backup files. | ||
# | ||
# In other words, type 'make' to compile everything; 'make check' to | ||
# compile and test everything, and 'make clean' to clean things up. | ||
# | ||
# You can use this file without understanding most of it, of course, but | ||
# I strongly recommend that you try to figure it out, and where you cannot, | ||
# that you ask questions. The Lab Reader contains documentation. | ||
|
||
# Name of package containing main procedure | ||
PACKAGE = gitlet | ||
|
||
# The name of the Python 3 program, used in the 'check' target. If your system | ||
# has a different name for this program (such as just "python"), run | ||
# the Makefile with | ||
# make PYTHON=python check | ||
PYTHON = python3 | ||
|
||
# Flags to pass to tester.py. | ||
TESTER_FLAGS = | ||
|
||
RMAKE = "$(MAKE)" | ||
|
||
# Targets that don't correspond to files, but are to be treated as commands. | ||
.PHONY: default check clean | ||
|
||
default: | ||
$(RMAKE) -C $(PACKAGE) default | ||
|
||
check: default | ||
$(RMAKE) -C testing PYTHON=$(PYTHON) TESTER_FLAGS="$(TESTER_FLAGS)" check | ||
|
||
# 'make clean' will clean up stuff you can reconstruct. | ||
clean: | ||
$(RM) *~ | ||
$(RMAKE) -C $(PACKAGE) clean | ||
$(RMAKE) -C testing clean | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Gitlet Design Document | ||
|
||
**Name**: | ||
|
||
## Classes and Data Structures | ||
|
||
### Class 1 | ||
|
||
#### Fields | ||
|
||
1. Field 1 | ||
2. Field 2 | ||
|
||
|
||
### Class 2 | ||
|
||
#### Fields | ||
|
||
1. Field 1 | ||
2. Field 2 | ||
|
||
|
||
## Algorithms | ||
|
||
## Persistence | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package gitlet; | ||
|
||
// TODO: any imports you need here | ||
|
||
import java.util.Date; // TODO: You'll likely use this in this class | ||
|
||
/** Represents a gitlet commit object. | ||
* TODO: It's a good idea to give a description here of what else this Class | ||
* does at a high level. | ||
* | ||
* @author TODO | ||
*/ | ||
public class Commit { | ||
/** | ||
* TODO: add instance variables here. | ||
* | ||
* List all instance variables of the Commit class here with a useful | ||
* comment above them describing what that variable represents and how that | ||
* variable is used. We've provided one example for `message`. | ||
*/ | ||
|
||
/** The message of this Commit. */ | ||
private String message; | ||
|
||
/* TODO: fill in the rest of this class. */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package gitlet; | ||
|
||
import java.io.File; | ||
|
||
/** A debugging class whose main program may be invoked as follows: | ||
* java gitlet.DumpObj FILE... | ||
* where each FILE is a file produced by Utils.writeObject (or any file | ||
* containing a serialized object). This will simply read FILE, | ||
* deserialize it, and call the dump method on the resulting Object. | ||
* The object must implement the gitlet.Dumpable interface for this | ||
* to work. For example, you might define your class like this: | ||
* | ||
* import java.io.Serializable; | ||
* import java.util.TreeMap; | ||
* class MyClass implements Serializeable, Dumpable { | ||
* ... | ||
* @Override | ||
* public void dump() { | ||
* System.out.printf("size: %d%nmapping: %s%n", _size, _mapping); | ||
* } | ||
* ... | ||
* int _size; | ||
* TreeMap<String, String> _mapping = new TreeMap<>(); | ||
* } | ||
* | ||
* As illustrated, your dump method should print useful information from | ||
* objects of your class. | ||
* @author P. N. Hilfinger | ||
*/ | ||
public class DumpObj { | ||
|
||
/** Deserialize and apply dump to the contents of each of the files | ||
* in FILES. */ | ||
public static void main(String... files) { | ||
for (String fileName : files) { | ||
Dumpable obj = Utils.readObject(new File(fileName), | ||
Dumpable.class); | ||
obj.dump(); | ||
System.out.println("---"); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package gitlet; | ||
|
||
import java.io.Serializable; | ||
|
||
/** An interface describing dumpable objects. | ||
* @author P. N. Hilfinger | ||
*/ | ||
interface Dumpable extends Serializable { | ||
/** Print useful information about this object on System.out. */ | ||
void dump(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package gitlet; | ||
|
||
/** General exception indicating a Gitlet error. For fatal errors, the | ||
* result of .getMessage() is the error message to be printed. | ||
* @author P. N. Hilfinger | ||
*/ | ||
class GitletException extends RuntimeException { | ||
|
||
|
||
/** A GitletException with no message. */ | ||
GitletException() { | ||
super(); | ||
} | ||
|
||
/** A GitletException MSG as its message. */ | ||
GitletException(String msg) { | ||
super(msg); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package gitlet; | ||
|
||
/** Driver class for Gitlet, a subset of the Git version-control system. | ||
* @author TODO | ||
*/ | ||
public class Main { | ||
|
||
/** Usage: java gitlet.Main ARGS, where ARGS contains | ||
* <COMMAND> <OPERAND1> <OPERAND2> ... | ||
*/ | ||
public static void main(String[] args) { | ||
// TODO: what if args is empty? | ||
String firstArg = args[0]; | ||
switch(firstArg) { | ||
case "init": | ||
// TODO: handle the `init` command | ||
break; | ||
case "add": | ||
// TODO: handle the `add [filename]` command | ||
break; | ||
// TODO: FILL THE REST IN | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# This makefile is defined to give you the following targets: | ||
# | ||
# default: The default target: Compiles $(PROG) and whatever it | ||
# depends on. | ||
# check: Compile $(PROG), if needed, and then for each file, F.in, in | ||
# directory testing, use F.in as input to "java $(MAIN_CLASS)" and | ||
# compare the output to the contents of the file names F.out. | ||
# Report discrepencies. | ||
# clean: Remove all the .class files produced by java compilation, | ||
# all Emacs backup files, and testing output files. | ||
# | ||
# In other words, type 'make' to compile everything; 'make check' to | ||
# compile and test everything, and 'make clean' to clean things up. | ||
# | ||
# You can use this file without understanding most of it, of course, but | ||
# I strongly recommend that you try to figure it out, and where you cannot, | ||
# that you ask questions. | ||
|
||
JFLAGS = -g -Xlint:unchecked -Xlint:deprecation | ||
|
||
CLASSDIR = ../classes | ||
|
||
# See comment in ../Makefile | ||
PYTHON = python3 | ||
|
||
RMAKE = "$(MAKE)" | ||
|
||
# A CLASSPATH value that (seems) to work on both Windows and Unix systems. | ||
# To Unix, it looks like ..:$(CLASSPATH):JUNK and to Windows like | ||
# JUNK;..;$(CLASSPATH). | ||
|
||
LIB = ../../library-sp21/javalib/* | ||
|
||
|
||
CPATH = "$(LIB):..:$(CLASSPATH):;$(LIB);..;$(CLASSPATH)" | ||
|
||
# All .java files in this directory. | ||
SRCS := $(wildcard *.java) | ||
|
||
.PHONY: default check clean | ||
|
||
# As a convenience, you can compile a single Java file X.java in this directory | ||
# with 'make X.class' | ||
%.class: %.java | ||
javac $(JFLAGS) -cp $(CPATH) $< | ||
|
||
# First, and therefore default, target. | ||
default: sentinel | ||
|
||
check: | ||
$(RMAKE) -C .. PYTHON=$(PYTHON) check | ||
|
||
integration: | ||
$(RMAKE) -C .. PYTHON=$(PYTHON) integration | ||
|
||
# 'make clean' will clean up stuff you can reconstruct. | ||
clean: | ||
$(RM) *~ *.class sentinel | ||
|
||
### DEPENDENCIES ### | ||
|
||
sentinel: $(SRCS) | ||
javac $(JFLAGS) -cp $(CPATH) $(SRCS) | ||
touch sentinel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package gitlet; | ||
|
||
import java.io.File; | ||
import static gitlet.Utils.*; | ||
|
||
// TODO: any imports you need here | ||
|
||
/** Represents a gitlet repository. | ||
* TODO: It's a good idea to give a description here of what else this Class | ||
* does at a high level. | ||
* | ||
* @author TODO | ||
*/ | ||
public class Repository { | ||
/** | ||
* TODO: add instance variables here. | ||
* | ||
* List all instance variables of the Repository class here with a useful | ||
* comment above them describing what that variable represents and how that | ||
* variable is used. We've provided two examples for you. | ||
*/ | ||
|
||
/** The current working directory. */ | ||
public static final File CWD = new File(System.getProperty("user.dir")); | ||
/** The .gitlet directory. */ | ||
public static final File GITLET_DIR = join(CWD, ".gitlet"); | ||
|
||
/* TODO: fill in the rest of this class. */ | ||
} |
Oops, something went wrong.