Skip to content

arnavsurve/vcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vcs

A simple version control system written in Go with the Cobra library for creating CLI applications. Inspired by Git and Build Your Own VCS by Ryan Heathcote.

installation

  1. Clone this repository

$ git clone git@github.com:arnavsurve/vcs.git && cd vcs

  1. Compile the vcs binary

$ go build -o vcs

usage

$ ./vcs
A simple version control system

Usage:
  vcs [command]

Available Commands:
  add         Add a file to the repository
  commit      Commit changes to the repository
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  init        Initialize a new repository
  status      Show the working tree status

Flags:
  -h, --help     help for vcs
  -t, --toggle   Help message for toggle

Use "vcs [command] --help" for more information about a command.

features

help

Prints a help message for vcs or for a specific command.

./vcs --help

# or

./vcs [command] --help

# or

./vcs help [command]

init

Creates the necessary directories and files for the repository, including the repository directory (.vcs), objects directory, and index file. If the repository already exists, a message is displayed indicating that the repository already exists.

add [filename]

Allows users to add a file to the repository. It checks if the file is ignored based on the patterns specified in the .vcsignore file. If the file is not ignored, it adds the file to the index and updates the index file with the new file's information.

commit -m "commit message"

Allows users to commit changes to the repository by providing a commit message.

status

Displays the working tree status, showing the changes to be committed and the unstaged changes. This command also checks the .vcsignore file for ignored patterns and computes the SHA1 hash of each file to compare with the index.

TODO

  • fix status showing to be committed after it is already committed

  • implement unstaging changes

  • implement diff

  • implement better pattern handling in .vcsignore

  • implement better pattern handling in add

    • e.g. go run main.go add . adds a file named "." rather than all unstaged files
  • handle multiple files being added at the same time

    > go run main.go add LICENSE README.md
    File added: LICENSE
    
  • implement commit history (git log)

About

Version control from scratch in Go 🪬

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages