b74186446e
--- type: change message: refactor commit interface to pass more information around change_hash: AIZfiSAG5eOrh4UUXaAaHLpEtmhgLwhKj5GrReujp/dO credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl52TUIACgkQlcRvpqQRSKwOOA/+IGXZF6fbhmRlnf1o11lF3eXXh4196GdCLaFsnwFj2cbPyv9H6hmOPQGGGqriRVZUIwAn5vpvHH3yxwi+3wSCrxVaOUUiwaN9NuWfc/4Qyhd+qMnjjrb+5WtCeCGO7LwSsK/YbFlKX9Bdvigen1AvyAY9e2jAr8BaRT4qeM+/OV8S+aQZIvO3nec2kzrwHul0aDxK8uRmmmLGZf5PPozVZgPkcl79f2dL6rG9wunCb6PSHnPXgvKpyxyzw9Rr2J2f/gi/Dfudmmux2eb8gfPz29pTR0jVBnVOb1p8HPZ+2+4Napcg+SW8cP0UlIa4pZ8X/Oqsy1DEcIQMTpj9BvjQTUa5D7wiBI0NY9imOuBPXIwFkU9SHca7rFdG7az6mmmMoU07CPQuULKglif7TZLXCXEz06rWJIzn/I3ZfWSXBIFIqne4BMsTIYiHi2EAn4eOxJnCsIXTW7lQ/b9xZjTGR5C6uBc9ChniMDIGm+PAAWF0Bdcls+Hj5wx3CdIBDCusaoCe2gFvX9oIKKbArQdKD5XTnQ8IO6X8lYTE0SWuhb9Szvoszxqn2qAFyKJ72O/X/O4opZxN3ZWDdyvHP/yfV6tQXqmBjM5XnEnKWcd3aqSg2yogoejW6B0lWqjnvG/yvZrZVvSKQWykCEaqcnYupjgpQuT3Mgo5odFUc/nn7kc= account: mediocregopher
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package dehub
|
|
|
|
import (
|
|
"dehub/yamlutil"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
|
)
|
|
|
|
// CommitCredential describes the structure of a credential commit message.
|
|
type CommitCredential struct {
|
|
CredentialedHash yamlutil.Blob `yaml:"credentialed_hash"`
|
|
}
|
|
|
|
var _ CommitInterface = CommitCredential{}
|
|
|
|
// NewCommitCredential constructs and returns a Commit populated with a
|
|
// CommitCredential encompassing the given hash. The Credentials of the returned
|
|
// Commit will _not_ be filled in.
|
|
func (r *Repo) NewCommitCredential(hash []byte) (Commit, error) {
|
|
return Commit{
|
|
Credential: &CommitCredential{
|
|
CredentialedHash: hash,
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
// MessageHead implements the method for the CommitInterface interface.
|
|
func (cc CommitCredential) MessageHead(common CommitCommon) (string, error) {
|
|
hash64 := base64.StdEncoding.EncodeToString(cc.CredentialedHash)
|
|
if len(hash64) > 6 {
|
|
hash64 = hash64[:6] + "..."
|
|
}
|
|
|
|
credAccounts := strings.Join(common.credAccountIDs(), ", ")
|
|
return fmt.Sprintf("Credential of hash %s by %s", hash64, credAccounts), nil
|
|
}
|
|
|
|
// Hash implements the method for the CommitInterface.
|
|
func (cc CommitCredential) Hash(_, _ *object.Tree) ([]byte, error) {
|
|
return cc.CredentialedHash, nil
|
|
}
|
|
|
|
// GetHash implements the method for the CommitInterface.
|
|
func (cc CommitCredential) GetHash() []byte {
|
|
return cc.CredentialedHash
|
|
}
|