aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-13 15:28:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-13 15:28:47 +0200
commitdf144e727a858ed07e3c9328d91efe052c4781e1 (patch)
treebfbfeea70f97ab3d4274c8e5add2c3aeeac1423b
parentf2f779c5a8b4efe67317bbffe110a9880c1f529a (diff)
downloadgit-bug-df144e727a858ed07e3c9328d91efe052c4781e1.tar.gz
fix some linting trouble
-rw-r--r--bug/bug.go30
-rw-r--r--bug/bug_actions.go5
-rw-r--r--bug/clocks.go2
-rw-r--r--bug/comment.go2
-rw-r--r--bug/operation.go11
-rw-r--r--bug/operation_pack.go6
-rw-r--r--bug/operations/label_change.go6
-rw-r--r--graphql/connections/connection_template.go10
-rw-r--r--graphql/connections/connections.go5
-rw-r--r--graphql/connections/gen_bug.go4
-rw-r--r--graphql/connections/gen_comment.go4
-rw-r--r--graphql/connections/gen_operation.go4
-rw-r--r--graphql/connections/lazy_bug.go2
-rw-r--r--graphql/models/edges.go3
-rw-r--r--graphql/relay.go2
-rw-r--r--graphql/resolvers/operations.go2
-rw-r--r--input/input.go26
-rw-r--r--repository/git.go7
-rw-r--r--repository/repo.go2
-rw-r--r--termui/termui.go1
-rw-r--r--util/hash.go4
-rw-r--r--webui/debug_assets.go3
22 files changed, 111 insertions, 30 deletions
diff --git a/bug/bug.go b/bug/bug.go
index 3c52adc8..7fa1dfb2 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -26,7 +26,7 @@ const humanIdLength = 7
// Bug hold the data of a bug thread, organized in a way close to
// how it will be persisted inside Git. This is the data structure
-// used for merge of two different version.
+// used to merge two different version of the same Bug.
type Bug struct {
// A Lamport clock is a logical clock that allow to order event
@@ -41,7 +41,7 @@ type Bug struct {
lastCommit util.Hash
rootPack util.Hash
- // all the commited operations
+ // all the committed operations
packs []OperationPack
// a temporary pack of operations used for convenience to pile up new operations
@@ -49,14 +49,14 @@ type Bug struct {
staging OperationPack
}
-// Create a new Bug
+// NewBug create a new Bug
func NewBug() *Bug {
// No id yet
// No logical clock yet
return &Bug{}
}
-// Find an existing Bug matching a prefix
+// FindLocalBug find an existing Bug matching a prefix
func FindLocalBug(repo repository.Repo, prefix string) (*Bug, error) {
ids, err := repo.ListIds(bugsRefPattern)
@@ -84,17 +84,19 @@ func FindLocalBug(repo repository.Repo, prefix string) (*Bug, error) {
return ReadLocalBug(repo, matching[0])
}
+// ReadLocalBug will read a local bug from its hash
func ReadLocalBug(repo repository.Repo, id string) (*Bug, error) {
ref := bugsRefPattern + id
return readBug(repo, ref)
}
+// ReadRemoteBug will read a remote bug from its hash
func ReadRemoteBug(repo repository.Repo, remote string, id string) (*Bug, error) {
ref := fmt.Sprintf(bugsRemoteRefPattern, remote) + id
return readBug(repo, ref)
}
-// Read and parse a Bug from git
+// readBug will read and parse a Bug from git
func readBug(repo repository.Repo, ref string) (*Bug, error) {
hashes, err := repo.ListCommits(ref)
@@ -212,12 +214,12 @@ type StreamedBug struct {
Err error
}
-// Read and parse all local bugs
+// ReadAllLocalBugs read and parse all local bugs
func ReadAllLocalBugs(repo repository.Repo) <-chan StreamedBug {
return readAllBugs(repo, bugsRefPattern)
}
-// Read and parse all remote bugs for a given remote
+// ReadAllRemoteBugs read and parse all remote bugs for a given remote
func ReadAllRemoteBugs(repo repository.Repo, remote string) <-chan StreamedBug {
refPrefix := fmt.Sprintf(bugsRemoteRefPattern, remote)
return readAllBugs(repo, refPrefix)
@@ -251,7 +253,7 @@ func readAllBugs(repo repository.Repo, refPrefix string) <-chan StreamedBug {
return out
}
-// List all the available local bug ids
+// ListLocalIds list all the available local bug ids
func ListLocalIds(repo repository.Repo) ([]string, error) {
return repo.ListIds(bugsRefPattern)
}
@@ -304,12 +306,12 @@ func (bug *Bug) Append(op Operation) {
bug.staging.Append(op)
}
-// Return if the bug need to be committed
+// HasPendingOp tell if the bug need to be committed
func (bug *Bug) HasPendingOp() bool {
return !bug.staging.IsEmpty()
}
-// Write the staging area in Git and move the operations to the packs
+// Commit write the staging area in Git and move the operations to the packs
func (bug *Bug) Commit(repo repository.Repo) error {
if bug.staging.IsEmpty() {
return fmt.Errorf("can't commit a bug with no pending operation")
@@ -515,6 +517,10 @@ func (bug *Bug) Merge(repo repository.Repo, other *Bug) (bool, error) {
// create a new commit with the correct ancestor
hash, err := repo.StoreCommitWithParent(treeHash, bug.lastCommit)
+ if err != nil {
+ return false, err
+ }
+
// replace the pack
newPack := pack.Clone()
newPack.commitHash = hash
@@ -533,7 +539,7 @@ func (bug *Bug) Merge(repo repository.Repo, other *Bug) (bool, error) {
return true, nil
}
-// Return the Bug identifier
+// Id return the Bug identifier
func (bug *Bug) Id() string {
if bug.id == "" {
// simply panic as it would be a coding error
@@ -543,7 +549,7 @@ func (bug *Bug) Id() string {
return bug.id
}
-// Return the Bug identifier truncated for human consumption
+// HumanId return the Bug identifier truncated for human consumption
func (bug *Bug) HumanId() string {
return formatHumanId(bug.Id())
}
diff --git a/bug/bug_actions.go b/bug/bug_actions.go
index 30fc9876..d4d5fe98 100644
--- a/bug/bug_actions.go
+++ b/bug/bug_actions.go
@@ -107,6 +107,11 @@ func MergeAll(repo repository.Repo, remote string) <-chan MergeResult {
localRef := bugsRefPattern + remoteBug.Id()
localExist, err := repo.RefExist(localRef)
+ if err != nil {
+ out <- newMergeError(id, err)
+ continue
+ }
+
// the bug is not local yet, simply create the reference
if !localExist {
err := repo.CopyRef(remoteRef, localRef)
diff --git a/bug/clocks.go b/bug/clocks.go
index 7b254746..5ffa094a 100644
--- a/bug/clocks.go
+++ b/bug/clocks.go
@@ -4,6 +4,8 @@ import (
"github.com/MichaelMure/git-bug/repository"
)
+// Witnesser will read all the available Bug to recreate the different logical
+// clocks
func Witnesser(repo *repository.GitRepo) error {
for b := range ReadAllLocalBugs(repo) {
if b.Err != nil {
diff --git a/bug/comment.go b/bug/comment.go
index 0b4fd6ad..ef5d9ef7 100644
--- a/bug/comment.go
+++ b/bug/comment.go
@@ -6,6 +6,7 @@ import (
"time"
)
+// Comment represent a comment in a Bug
type Comment struct {
Author Person
Message string
@@ -16,6 +17,7 @@ type Comment struct {
UnixTime int64
}
+// FormatTime format the UnixTime of the comment for human consumption
func (c Comment) FormatTime() string {
t := time.Unix(c.UnixTime, 0)
return humanize.Time(t)
diff --git a/bug/operation.go b/bug/operation.go
index 3949ac7b..cdf87931 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -5,6 +5,7 @@ import (
"time"
)
+// OperationType is an identifier
type OperationType int
const (
@@ -16,22 +17,29 @@ const (
LabelChangeOp
)
+// Operation define the interface to fulfill for an edit operation of a Bug
type Operation interface {
+ // OpType return the type of operation
OpType() OperationType
+ // Time return the time when the operation was added
Time() time.Time
+ // Apply the operation to a Snapshot to create the final state
Apply(snapshot Snapshot) Snapshot
+ // Files return the files needed by this operation
Files() []util.Hash
// TODO: data validation (ex: a title is a single line)
// Validate() bool
}
+// OpBase implement the common code for all operations
type OpBase struct {
OperationType OperationType
Author Person
UnixTime int64
}
+// NewOpBase is the constructor for an OpBase
func NewOpBase(opType OperationType, author Person) OpBase {
return OpBase{
OperationType: opType,
@@ -40,14 +48,17 @@ func NewOpBase(opType OperationType, author Person) OpBase {
}
}
+// OpType return the type of operation
func (op OpBase) OpType() OperationType {
return op.OperationType
}
+// Time return the time when the operation was added
func (op OpBase) Time() time.Time {
return time.Unix(op.UnixTime, 0)
}
+// Files return the files needed by this operation
func (op OpBase) Files() []util.Hash {
return nil
}
diff --git a/bug/operation_pack.go b/bug/operation_pack.go
index cce1845c..5de60bde 100644
--- a/bug/operation_pack.go
+++ b/bug/operation_pack.go
@@ -20,6 +20,7 @@ type OperationPack struct {
commitHash util.Hash
}
+// ParseOperationPack will deserialize an OperationPack from raw bytes
func ParseOperationPack(data []byte) (*OperationPack, error) {
reader := bytes.NewReader(data)
decoder := gob.NewDecoder(reader)
@@ -35,6 +36,7 @@ func ParseOperationPack(data []byte) (*OperationPack, error) {
return &opp, nil
}
+// Serialize will serialise an OperationPack into raw bytes
func (opp *OperationPack) Serialize() ([]byte, error) {
var data bytes.Buffer
@@ -53,14 +55,18 @@ func (opp *OperationPack) Append(op Operation) {
opp.Operations = append(opp.Operations, op)
}
+// IsEmpty tell if the OperationPack is empty
func (opp *OperationPack) IsEmpty() bool {
return len(opp.Operations) == 0
}
+// IsValid tell if the OperationPack is considered valid
func (opp *OperationPack) IsValid() bool {
return !opp.IsEmpty()
}
+// Write will serialize and store the OperationPack as a git blob and return
+// its hash
func (opp *OperationPack) Write(repo repository.Repo) (util.Hash, error) {
data, err := opp.Serialize()
diff --git a/bug/operations/label_change.go b/bug/operations/label_change.go
index 85bae595..8f608dbc 100644
--- a/bug/operations/label_change.go
+++ b/bug/operations/label_change.go
@@ -9,16 +9,16 @@ import (
"github.com/MichaelMure/git-bug/bug"
)
-// LabelChangeOperation will add or remove a set of labels
-
var _ bug.Operation = LabelChangeOperation{}
+// LabelChangeOperation define a Bug operation to add or remove labels
type LabelChangeOperation struct {
bug.OpBase
Added []bug.Label
Removed []bug.Label
}
+// Apply apply the operation
func (op LabelChangeOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
// Add in the set
AddLoop:
@@ -59,7 +59,7 @@ func NewLabelChangeOperation(author bug.Person, added, removed []bug.Label) Labe
}
}
-// Convenience function to apply the operation
+// ChangeLabels is a convenience function to apply the operation
func ChangeLabels(out io.Writer, b *bug.Bug, author bug.Person, add, remove []string) error {
var added, removed []bug.Label
diff --git a/graphql/connections/connection_template.go b/graphql/connections/connection_template.go
index a4608430..511f48d3 100644
--- a/graphql/connections/connection_template.go
+++ b/graphql/connections/connection_template.go
@@ -2,22 +2,32 @@ package connections
import (
"fmt"
+
"github.com/MichaelMure/git-bug/graphql/models"
"github.com/cheekybits/genny/generic"
)
+// NodeType define the node type handled by this relay connection
type NodeType generic.Type
+
+// EdgeType define the edge type handled by this relay connection
type EdgeType generic.Type
+
+// ConnectionType define the connection type handled by this relay connection
type ConnectionType generic.Type
+// NodeTypeEdger define a function that take a NodeType and an offset and
+// create an Edge.
type NodeTypeEdger func(value NodeType, offset int) Edge
+// NodeTypeConMaker define a function that create a ConnectionType
type NodeTypeConMaker func(
edges []EdgeType,
nodes []NodeType,
info models.PageInfo,
totalCount int) (ConnectionType, error)
+// NodeTypeCon will paginate a source according to the input of a relay connection
func NodeTypeCon(source []NodeType, edger NodeTypeEdger, conMaker NodeTypeConMaker, input models.ConnectionInput) (ConnectionType, error) {
var nodes []NodeType
var edges []EdgeType
diff --git a/graphql/connections/connections.go b/graphql/connections/connections.go
index 84dc3750..8b905fab 100644
--- a/graphql/connections/connections.go
+++ b/graphql/connections/connections.go
@@ -13,17 +13,18 @@ import (
const cursorPrefix = "cursor:"
+// Edge define the contract for an edge in a relay connection
type Edge interface {
GetCursor() string
}
-// Creates the cursor string from an offset
+// OffsetToCursor create the cursor string from an offset
func OffsetToCursor(offset int) string {
str := fmt.Sprintf("%v%v", cursorPrefix, offset)
return base64.StdEncoding.EncodeToString([]byte(str))
}
-// Re-derives the offset from the cursor string.
+// CursorToOffset re-derives the offset from the cursor string.
func CursorToOffset(cursor string) (int, error) {
str := ""
b, err := base64.StdEncoding.DecodeString(cursor)
diff --git a/graphql/connections/gen_bug.go b/graphql/connections/gen_bug.go
index 9224c696..e9654986 100644
--- a/graphql/connections/gen_bug.go
+++ b/graphql/connections/gen_bug.go
@@ -10,14 +10,18 @@ import (
"github.com/MichaelMure/git-bug/graphql/models"
)
+// StringEdger define a function that take a string and an offset and
+// create an Edge.
type StringEdger func(value string, offset int) Edge
+// StringConMaker define a function that create a models.BugConnection
type StringConMaker func(
edges []LazyBugEdge,
nodes []string,
info models.PageInfo,
totalCount int) (models.BugConnection, error)
+// StringCon will paginate a source according to the input of a relay connection
func StringCon(source []string, edger StringEdger, conMaker StringConMaker, input models.ConnectionInput) (models.BugConnection, error) {
var nodes []string
var edges []LazyBugEdge
diff --git a/graphql/connections/gen_comment.go b/graphql/connections/gen_comment.go
index 0253e831..57fad3af 100644
--- a/graphql/connections/gen_comment.go
+++ b/graphql/connections/gen_comment.go
@@ -11,14 +11,18 @@ import (
"github.com/MichaelMure/git-bug/graphql/models"
)
+// BugCommentEdger define a function that take a bug.Comment and an offset and
+// create an Edge.
type BugCommentEdger func(value bug.Comment, offset int) Edge
+// BugCommentConMaker define a function that create a models.CommentConnection
type BugCommentConMaker func(
edges []models.CommentEdge,
nodes []bug.Comment,
info models.PageInfo,
totalCount int) (models.CommentConnection, error)
+// BugCommentCon will paginate a source according to the input of a relay connection
func BugCommentCon(source []bug.Comment, edger BugCommentEdger, conMaker BugCommentConMaker, input models.ConnectionInput) (models.CommentConnection, error) {
var nodes []bug.Comment
var edges []models.CommentEdge
diff --git a/graphql/connections/gen_operation.go b/graphql/connections/gen_operation.go
index 26936dfe..570c67cd 100644
--- a/graphql/connections/gen_operation.go
+++ b/graphql/connections/gen_operation.go
@@ -11,14 +11,18 @@ import (
"github.com/MichaelMure/git-bug/graphql/models"
)
+// BugOperationEdger define a function that take a bug.Operation and an offset and
+// create an Edge.
type BugOperationEdger func(value bug.Operation, offset int) Edge
+// BugOperationConMaker define a function that create a models.OperationConnection
type BugOperationConMaker func(
edges []models.OperationEdge,
nodes []bug.Operation,
info models.PageInfo,
totalCount int) (models.OperationConnection, error)
+// BugOperationCon will paginate a source according to the input of a relay connection
func BugOperationCon(source []bug.Operation, edger BugOperationEdger, conMaker BugOperationConMaker, input models.ConnectionInput) (models.OperationConnection, error) {
var nodes []bug.Operation
var edges []models.OperationEdge
diff --git a/graphql/connections/lazy_bug.go b/graphql/connections/lazy_bug.go
index 35dcb687..24eda0b6 100644
--- a/graphql/connections/lazy_bug.go
+++ b/graphql/connections/lazy_bug.go
@@ -1,10 +1,12 @@
package connections
+// LazyBugEdge is a special relay edge used to implement a lazy loading connection
type LazyBugEdge struct {
Id string
Cursor string
}
+// GetCursor return the cursor of a LazyBugEdge
func (lbe LazyBugEdge) GetCursor() string {
return lbe.Cursor
}
diff --git a/graphql/models/edges.go b/graphql/models/edges.go
index 677d13f5..7de76edf 100644
--- a/graphql/models/edges.go
+++ b/graphql/models/edges.go
@@ -1,13 +1,16 @@
package models
+// GetCursor return the cursor entry of an edge
func (e OperationEdge) GetCursor() string {
return e.Cursor
}
+// GetCursor return the cursor entry of an edge
func (e BugEdge) GetCursor() string {
return e.Cursor
}
+// GetCursor return the cursor entry of an edge
func (e CommentEdge) GetCursor() string {
return e.Cursor
}
diff --git a/graphql/relay.go b/graphql/relay.go
index a73a38ef..036ab54e 100644
--- a/graphql/relay.go
+++ b/graphql/relay.go
@@ -5,7 +5,6 @@ import (
"strings"
)
-
type ResolvedGlobalID struct {
Type string `json:"type"`
ID string `json:"id"`
@@ -36,4 +35,3 @@ func FromGlobalID(globalID string) *ResolvedGlobalID {
ID: tokens[1],
}
}
-
diff --git a/graphql/resolvers/operations.go b/graphql/resolvers/operations.go
index 7fb3f3e2..086bc249 100644
--- a/graphql/resolvers/operations.go
+++ b/graphql/resolvers/operations.go
@@ -5,8 +5,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/bug/operations"
- "time"
"github.com/MichaelMure/git-bug/graphql/models"
+ "time"
)
type addCommentOperationResolver struct{}
diff --git a/input/input.go b/input/input.go
index 2986fae5..43fb9613 100644
--- a/input/input.go
+++ b/input/input.go
@@ -16,7 +16,10 @@ import (
const messageFilename = "BUG_MESSAGE_EDITMSG"
+// ErrEmptyMessage is returned when the required message has not been entered
var ErrEmptyMessage = errors.New("empty message")
+
+// ErrEmptyMessage is returned when the required title has not been entered
var ErrEmptyTitle = errors.New("empty title")
const bugTitleCommentTemplate = `%s%s
@@ -26,6 +29,9 @@ const bugTitleCommentTemplate = `%s%s
# An empty title aborts the operation.
`
+// BugCreateEditorInput will open the default editor in the terminal with a
+// template for the user to fill. The file is then processed to extract title
+// and message.
func BugCreateEditorInput(repo repository.Repo, preTitle string, preMessage string) (string, string, error) {
if preMessage != "" {
preMessage = "\n\n" + preMessage
@@ -33,7 +39,7 @@ func BugCreateEditorInput(repo repository.Repo, preTitle string, preMessage stri
template := fmt.Sprintf(bugTitleCommentTemplate, preTitle, preMessage)
- raw, err := LaunchEditorWithTemplate(repo, messageFilename, template)
+ raw, err := launchEditorWithTemplate(repo, messageFilename, template)
if err != nil {
return "", "", err
@@ -75,8 +81,10 @@ const bugCommentTemplate = `
# and an empty message aborts the operation.
`
+// BugCommentEditorInput will open the default editor in the terminal with a
+// template for the user to fill. The file is then processed to extract a comment.
func BugCommentEditorInput(repo repository.Repo) (string, error) {
- raw, err := LaunchEditorWithTemplate(repo, messageFilename, bugCommentTemplate)
+ raw, err := launchEditorWithTemplate(repo, messageFilename, bugCommentTemplate)
if err != nil {
return "", err
@@ -108,9 +116,11 @@ const bugTitleTemplate = `%s
# Lines starting with '#' will be ignored, and an empty title aborts the operation.
`
+// BugTitleEditorInput will open the default editor in the terminal with a
+// template for the user to fill. The file is then processed to extract a title.
func BugTitleEditorInput(repo repository.Repo, preTitle string) (string, error) {
template := fmt.Sprintf(bugTitleTemplate, preTitle)
- raw, err := LaunchEditorWithTemplate(repo, messageFilename, template)
+ raw, err := launchEditorWithTemplate(repo, messageFilename, template)
if err != nil {
return "", err
@@ -138,7 +148,9 @@ func BugTitleEditorInput(repo repository.Repo, preTitle string) (string, error)
return title, nil
}
-func LaunchEditorWithTemplate(repo repository.Repo, fileName string, template string) (string, error) {
+// launchEditorWithTemplate will launch an editor as launchEditor do, but with a
+// provided template.
+func launchEditorWithTemplate(repo repository.Repo, fileName string, template string) (string, error) {
path := fmt.Sprintf("%s/.git/%s", repo.GetPath(), fileName)
err := ioutil.WriteFile(path, []byte(template), 0644)
@@ -147,10 +159,10 @@ func LaunchEditorWithTemplate(repo repository.Repo, fileName string, template st
return "", err
}
- return LaunchEditor(repo, fileName)
+ return launchEditor(repo, fileName)
}
-// LaunchEditor launches the default editor configured for the given repo. This
+// launchEditor launches the default editor configured for the given repo. This
// method blocks until the editor command has returned.
//
// The specified filename should be a temporary file and provided as a relative path
@@ -159,7 +171,7 @@ func LaunchEditorWithTemplate(repo repository.Repo, fileName string, template st
//
// This method returns the text that was read from the temporary file, or
// an error if any step in the process failed.
-func LaunchEditor(repo repository.Repo, fileName string) (string, error) {
+func launchEditor(repo repository.Repo, fileName string) (string, error) {
path := fmt.Sprintf("%s/.git/%s", repo.GetPath(), fileName)
defer os.Remove(path)
diff --git a/repository/git.go b/repository/git.go
index dc071fdc..d55def9e 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -17,6 +17,7 @@ import (
const createClockFile = "/.git/git-bug/create-clock"
const editClockFile = "/.git/git-bug/edit-clock"
+// ErrNotARepo is the error returned when the git repo root wan't be found
var ErrNotARepo = errors.New("not a git repository")
// GitRepo represents an instance of a (local) git repository.
@@ -106,6 +107,7 @@ func NewGitRepo(path string, witnesser func(repo *GitRepo) error) (*GitRepo, err
return repo, nil
}
+// InitGitRepo create a new empty git repo at the given path
func InitGitRepo(path string) (*GitRepo, error) {
repo := &GitRepo{Path: path}
repo.createClocks()
@@ -118,6 +120,7 @@ func InitGitRepo(path string) (*GitRepo, error) {
return repo, nil
}
+// InitBareGitRepo create a new --bare empty git repo at the given path
func InitBareGitRepo(path string) (*GitRepo, error) {
repo := &GitRepo{Path: path}
repo.createClocks()
@@ -332,7 +335,7 @@ func (repo *GitRepo) FindCommonAncestor(hash1 util.Hash, hash2 util.Hash) (util.
return util.Hash(stdout), nil
}
-// Return the git tree hash referenced in a commit
+// GetTreeHash return the git tree hash referenced in a commit
func (repo *GitRepo) GetTreeHash(commit util.Hash) (util.Hash, error) {
stdout, err := repo.runGitCommand("rev-parse", string(commit)+"^{tree}")
@@ -343,7 +346,7 @@ func (repo *GitRepo) GetTreeHash(commit util.Hash) (util.Hash, error) {
return util.Hash(stdout), nil
}
-// Add a new remote to the repository
+// AddRemote add a new remote to the repository
// Not in the interface because it's only used for testing
func (repo *GitRepo) AddRemote(name string, url string) error {
_, err := repo.runGitCommand("remote", "add", name, url)
diff --git a/repository/repo.go b/repository/repo.go
index 372a8066..9ffb470e 100644
--- a/repository/repo.go
+++ b/repository/repo.go
@@ -67,7 +67,7 @@ type Repo interface {
// FindCommonAncestor will return the last common ancestor of two chain of commit
FindCommonAncestor(hash1 util.Hash, hash2 util.Hash) (util.Hash, error)
- // Return the git tree hash referenced in a commit
+ // GetTreeHash return the git tree hash referenced in a commit
GetTreeHash(commit util.Hash) (util.Hash, error)
LoadClocks() error
diff --git a/termui/termui.go b/termui/termui.go
index b45bbc2e..0d3bc56e 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -41,6 +41,7 @@ type window interface {
disable(g *gocui.Gui) error
}
+// Run will launch the termUI in the terminal
func Run(repo repository.Repo) error {
c := cache.NewRepoCache(repo)
diff --git a/util/hash.go b/util/hash.go
index df0a83b8..0a3964a0 100644
--- a/util/hash.go
+++ b/util/hash.go
@@ -5,12 +5,14 @@ import (
"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 {
@@ -26,10 +28,12 @@ func (h *Hash) UnmarshalGQL(v interface{}) error {
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
diff --git a/webui/debug_assets.go b/webui/debug_assets.go
index 4027ecf1..52b76df5 100644
--- a/webui/debug_assets.go
+++ b/webui/debug_assets.go
@@ -4,4 +4,7 @@ package webui
import "net/http"
+// WebUIAssets give access to the files of the Web UI for a http handler
+// This access is only used in a debug build to be able to edit the WebUI
+// files without having to package them.
var WebUIAssets http.FileSystem = http.Dir("webui/build")