--- type: change message: Implement credential commit object, but don't use it anywhere yet change_hash: AIJRxhlQQuDhoByl1nApcFrRhlS9bK+4w/6JYl8SHl9o credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl5hjqYACgkQlcRvpqQRSKyD5Q/+MTE6eiKXA0dicHXzv7DR48BMmXwD9wgekF5s49hUOh70+zmPvSypTI3hbnN4lfRnubTvrCZDBwxwhb5q6DRNosNGoBdUj5ofzpsyOJwoy7+htPJrZci6aAzy2uTcVMdqyaqbrDx9RAXGpqui1pZlS+kyUWlhMy4WT6ilJEHVDwqzVw6YcemflcdE6tc+ufqbkmVSy9uAMHLd6a5iegsbX0g/qwME7Qx07yWsuqwfD6FMCeEwtwk9FIkIkPAASZz0u4BlNy6g2KtGrWRraO9i2sQJyLoXh1/vhxCEX9oq0HrzutECgodaDBIFCnZd4NrDSeRPRHKxYF1/rWCUIkPzTMtQR5tGY2CYMCfTC1gBzb5UuJlkAi/D6TTaZO1JWwl2J7R9701D0aEds8w3FFVxOmggwtXonX5mjkYMLyEGVzinPjgtQBgZJQDZ4mIXhUaG8U0vhmo5pQFLAokKXWTo/Jbwm8MZ6SaiLmtGzGm+VoU4sGyUmVURC9X3bv8UjxFJrDibOnmEkfodNzkBsMow0y2gw78XaAME5h4TlBqjCof5iFc9gIBZWskOJYXcEenjChYADwt6Yvfm9UHhXeP8DSb0UtXz3se/PkUrjsC8bCqESncDYyB8QvIcNQY3eiZvRnSTU+m67ME5fuh6ANK5yvwcUIficG9hAVroUwu5eU4= account: mediocregophermain
parent
51af20fbc0
commit
c87baa5192
@ -0,0 +1,46 @@ |
|||||||
|
package dehub |
||||||
|
|
||||||
|
import ( |
||||||
|
"dehub/yamlutil" |
||||||
|
"encoding/base64" |
||||||
|
"fmt" |
||||||
|
|
||||||
|
"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() (string, error) { |
||||||
|
hash64 := base64.StdEncoding.EncodeToString(cc.CredentialedHash) |
||||||
|
if len(hash64) > 6 { |
||||||
|
hash64 = hash64[:6] + "..." |
||||||
|
} |
||||||
|
return fmt.Sprintf("Credential of hash %s", hash64), 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 |
||||||
|
} |
Loading…
Reference in new issue