// 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) }
// 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 }