Esempio n. 1
0
func (store FolderStore) AddEntry(name data.ProjectName, entry data.Entry) error {
	db := store.db()
	err := db.Put(entry.Values(), name.Values()...)
	if err != nil {
		return errgo.Notef(err, "can not put entry into the database")
	}

	return nil
}
Esempio n. 2
0
//Commit will add and commit the given entry into the repository that lays unter
//the given datadir.
func Commit(datadir string, project data.ProjectName, entry data.Entry) error {
	err := gitAdd(datadir, ".")
	if err != nil {
		return errgo.Notef(err, "can not add file to repository")
	}

	message := project.String() + " - " + entry.Type().String() + " - " +
		entry.GetTimeStamp().Format(data.TimeStampFormat)

	err = gitCommit(datadir, message)
	if err != nil {
		return errgo.Notef(err, "can not commit file to repository")
	}

	return nil
}
Esempio n. 3
0
func (store FolderStore) GetProject(name data.ProjectName) (data.Project, error) {
	db := store.db()
	values, err := db.Get(name.Values()...)
	if err != nil {
		return data.Project{}, errgo.Notef(err, "can not put entry into the database")
	}

	var entries []data.Entry
	for _, value := range values {
		entry, err := data.ParseEntry(value)
		if err != nil {
			return data.Project{}, errgo.Notef(err, "can not parse entry from value")
		}

		entries = append(entries, entry)
	}

	return data.Project{Name: name, Entries: entries}, nil
}