Exemplo n.º 1
0
// saveRepository saves a repository in the store.
func (s *Store) saveRepository(tx *bolt.Tx, r *internal.Repository) error {
	buf, err := proto.Marshal(r)
	if err != nil {
		return err
	}
	return tx.Bucket([]byte("repositories")).Put([]byte(r.GetID()), buf)
}
Exemplo n.º 2
0
// decodeRepository decodes pb into an application type.
func decodeRepository(pb *internal.Repository) *Repository {
	r := &Repository{
		ID:          pb.GetID(),
		Description: pb.GetDescription(),
		Language:    pb.GetLanguage(),
		Notified:    pb.GetNotified(),
		Messages:    make([]*Message, len(pb.Messages)),
	}

	for i, m := range pb.GetMessages() {
		r.Messages[i] = decodeMessage(m)
	}

	return r
}