aboutsummaryrefslogtreecommitdiffstats
path: root/util/hash.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-11 22:04:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-11 22:14:46 +0200
commit3605887345792d2f981f971c6c4a2cb7f86a343e (patch)
treeafd525b6e3a638e4c619a5a986fcb2811c297444 /util/hash.go
parent7b05983c19af4da70f2a9a5062913f4e4f5d5faa (diff)
downloadgit-bug-3605887345792d2f981f971c6c4a2cb7f86a343e.tar.gz
reorganize package for a more idomatic go
Diffstat (limited to 'util/hash.go')
-rw-r--r--util/hash.go47
1 files changed, 0 insertions, 47 deletions
diff --git a/util/hash.go b/util/hash.go
deleted file mode 100644
index 0a3964a0..00000000
--- a/util/hash.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package util
-
-import (
- "fmt"
- "io"
-)
-
-// Hash is a git hash
-type Hash string
-
-func (h Hash) String() string {
- return string(h)
-}
-
-// UnmarshalGQL implement the Unmarshaler interface for gqlgen
-func (h *Hash) UnmarshalGQL(v interface{}) error {
- _, ok := v.(string)
- if !ok {
- return fmt.Errorf("labels must be strings")
- }
-
- *h = v.(Hash)
-
- if !h.IsValid() {
- return fmt.Errorf("invalid hash")
- }
-
- return nil
-}
-
-// MarshalGQL implement the Marshaler interface for gqlgen
-func (h Hash) MarshalGQL(w io.Writer) {
- w.Write([]byte(`"` + h.String() + `"`))
-}
-
-// IsValid tell if the hash is valid
-func (h *Hash) IsValid() bool {
- if len(*h) != 40 {
- return false
- }
- for _, r := range *h {
- if (r < 'a' || r > 'z') && (r < '0' || r > '9') {
- return false
- }
- }
- return true
-}