Skip to content

HWRoboticsHelper1/git-project-andrew-jo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-project-andrew-jo

initializeRepo: Call initializeRepo() to create the basic infrastructure for a git project. It'll create a git directory and populate it with an objects directory, index file, and HEAD file if those directories/files don't exist. Otherwise, it'll leave them as is. If the initialization adds anything, it'll let you know the repo has been successfully created. If you started with all of that infrastructure, it'll let you know the repo already exists.

hashFile: The hashFile function takes in a file path and returns the hexstring of the contents of the file hashed by SHA-1. It usues two helper functions, extractContent, which tries to open the file and get the content in the file. Will throw a FileNotFoundException if the file path doesn't exist. Then, hashContent will take the content and return the hash string in hex, using helper functions getSHA to do the hashing and toHexString to turn it to hex.

blobFile: Call blobFile on a filePath to create a file in git/objects that will have a fileName based on the hash of the contents of the original file and then populate it with the contents of the original file. Will also return the hash of the file's contents if you want. Full tester is avialable in GitTester.java

indexFile: Takes a file path as a string and will write the file content's hash + space + filename in a new line in the git/index file. If that file already exists in the index file, the hash will be updated to reflect any changes in content.

hashTree: Call hashTree on a directory path to create a file in git/objects that contains a list of all the files and subdirectories in it with their hashes. The file name will be the hash of the resulting file. Returns the hash of the tree object.

makeIndexTree: Makes all the blobs and trees necessary to save state of all files listed in index file, then makes one final root file. Lots of helper functions were involved, plus an ObjectEntry class which holds the objectPath, objectHash, whether the object is a file or directory, and its depth in terms of number of directories deep.

makeCommit: Makes a commit object and file given a message and an author. This commit holds the previous commit in it, and is stored in the HEAD file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages