func Commit(dir string, message string, metadata ...string) (oid string) {
	log.Println("Snapshoting the following directory : ", dir)
	oidTree, err := WriteTree(dir)
	if err != nil {
		log.Println(err)
		return ""
	}

	ref, err := storage.GetHead()
	if err != nil {
		log.Println(err)
		return ""
	}

	oidParent, _ := GetOid(ref)
	commit := fmt.Sprintf("%s %s\n", storage.TREE, oidTree)
	commit += fmt.Sprintf("%s %s\n", storage.PARENT, oidParent)
	commit += fmt.Sprintf("\n%s", message)

	oid, err = storage.PutObject(commit, storage.COMMIT)
	if err != nil {
		log.Println(err)
		return ""
	}

	storage.SetRef(ref, oid)
	return oid
}
/*
Commit takes a snapshot of the directory and add message plus metadata
*/
Commit takes a snapshot of the directory and add message plus metadata
/ * Commit takes a snapshot of the directory and add message plus metadata * /
func Commit(dir string, message string, metadata ...string) (oid string) {
	log.Println("Snapshoting the following directory : ", dir)
	oidTree, err := WriteTree(dir)
	if err != nil {
		log.Println(err)
		return ""
	}
	ref, err := storage.GetHead()
	if err != nil {
		log.Println(err)
		return ""
	}
	oidParent, _ := GetOid(ref)
	commit := fmt.Sprintf("%s %s\n", storage.TREE, oidTree)
	commit += fmt.Sprintf("%s %s\n", storage.PARENT, oidParent)
	commit += fmt.Sprintf("\n%s", message)
	oid, err = storage.PutObject(commit, storage.COMMIT)
	if err != nil {
		log.Println(err)
		return ""
	}
	storage.SetRef(ref, oid)
	return oid
}
func Commit ( dir string , message string , metadata ... string ) ( oid string ) { log . Println ( " " , dir ) oidTree , err := WriteTree ( dir ) if err != nil { log . Println ( err ) return " " } ref , err := storage . GetHead ( ) if err != nil { log . Println ( err ) return " " } oidParent , _ := GetOid ( ref ) commit := fmt . Sprintf ( " \n " , storage . TREE , oidTree ) commit += fmt . Sprintf ( " \n " , storage . PARENT , oidParent ) commit += fmt . Sprintf ( " \n " , message ) oid , err = storage . PutObject ( commit , storage . COMMIT ) if err != nil { log . Println ( err ) return " " } storage . SetRef ( ref , oid ) return oid }
Commit takes a snapshot of the directory and add message plus metadata
Commit takes a snapshot of the directory and add message plus metadata