Beispiel #1
0
// Open returns the metadata file for the current repo (if it exists)
func Open() (*Repo, error) {
	// Find file location
	curDir, file, err := dirutils.GetCurrentDirectory()
	if err != nil {
		return nil, err
	}
	defer file.Close()

	exists, dir := dirutils.RecursivelyCheckForRepo(file)
	if !exists {
		err = fmt.Errorf("No existing SVC repo found in %s", curDir)
		return nil, err
	}

	filename := dir + "/" + dirutils.ObjectDir + "/" + metafileName
	repo := ReadMetadata(filename)
	return repo, nil
}
Beispiel #2
0
// Initializes an empty repo in current directory.
func Initialize() {
	curDir, file, err := dirutils.GetCurrentDirectory()
	if err != nil {
		panic(err)
	}

	// Check if already in repo
	exists, dir := dirutils.RecursivelyCheckForRepo(file)
	if exists {
		fmt.Printf("Found existing SVC repo in %s\n", dir)
		return
	}

	fmt.Printf("Initializing empty repo in %s\n", curDir)

	// Make .svc directory and create metadata file
	dirutils.InitializeRepo()
	meta.InitializeRepo()
}