[misc] update man docs and completion scripts

Amine Hilaly created

[cache] BugCache: Fix set metadata raw

[bridge/github] Fix graphql input objects

Change summary

bridge/github/export.go       | 27 ++++++++++++--------
cache/bug_cache.go            |  2 
doc/man/git-bug-bridge-push.1 | 29 +++++++++++++++++++++
doc/man/git-bug-bridge.1      |  2 
doc/md/git-bug_bridge.md      |  1 
doc/md/git-bug_bridge_push.md | 22 ++++++++++++++++
misc/bash_completion/git-bug  | 21 +++++++++++++++
misc/zsh_completion/git-bug   | 49 +++++++++++++++++++++++++++++++++++++
8 files changed, 140 insertions(+), 13 deletions(-)

Detailed changes

bridge/github/export.go 🔗

@@ -22,6 +22,9 @@ import (
 type githubExporter struct {
 	conf core.Configuration
 
+	// number of exported bugs
+	exportedBugs int
+
 	// export only bugs taged with one of these origins
 	onlyOrigins []string
 
@@ -166,12 +169,11 @@ func (ge *githubExporter) exportBug(b *cache.BugCache, since time.Time) error {
 	// get github bug ID
 	githubID, ok := createOp.GetMetadata(keyGithubId)
 	if ok {
-		githubURL, ok := createOp.GetMetadata(keyGithubId)
+		githubURL, ok := createOp.GetMetadata(keyGithubUrl)
 		if !ok {
 			// if we find github ID, github URL must be found too
 			panic("expected to find github issue URL")
 		}
-
 		// will be used to mark operation related to a bug as exported
 		bugGithubID = githubID
 		bugGithubURL = githubURL
@@ -191,7 +193,7 @@ func (ge *githubExporter) exportBug(b *cache.BugCache, since time.Time) error {
 		// create bug
 		id, url, err := createGithubIssue(client, ge.repositoryID, createOp.Title, createOp.Message)
 		if err != nil {
-			return fmt.Errorf("creating exporting github issue %v", err)
+			return fmt.Errorf("exporting github issue: %v", err)
 		}
 
 		hash, err := createOp.Hash()
@@ -263,11 +265,13 @@ func (ge *githubExporter) exportBug(b *cache.BugCache, since time.Time) error {
 			}
 
 		case *bug.EditCommentOperation:
+
 			opr := op.(*bug.EditCommentOperation)
 			targetHash := opr.Target.String()
 
 			// Since github doesn't consider the issue body as a comment
 			if targetHash == bugCreationHash {
+
 				// case bug creation operation: we need to edit the Github issue
 				if err := updateGithubIssueBody(client, bugGithubID, opr.Message); err != nil {
 					return fmt.Errorf("editing issue: %v", err)
@@ -277,6 +281,7 @@ func (ge *githubExporter) exportBug(b *cache.BugCache, since time.Time) error {
 				url = bugGithubURL
 
 			} else {
+
 				// case comment edition operation: we need to edit the Github comment
 				commentID, ok := ge.cachedIDs[targetHash]
 				if !ok {
@@ -552,7 +557,7 @@ func (ge *githubExporter) getLabelsIDs(repositoryID string, labels []bug.Label)
 // create a github issue and return it ID
 func createGithubIssue(gc *githubv4.Client, repositoryID, title, body string) (string, string, error) {
 	m := &createIssueMutation{}
-	input := &githubv4.CreateIssueInput{
+	input := githubv4.CreateIssueInput{
 		RepositoryID: repositoryID,
 		Title:        githubv4.String(title),
 		Body:         (*githubv4.String)(&body),
@@ -569,7 +574,7 @@ func createGithubIssue(gc *githubv4.Client, repositoryID, title, body string) (s
 // add a comment to an issue and return it ID
 func addCommentGithubIssue(gc *githubv4.Client, subjectID string, body string) (string, string, error) {
 	m := &addCommentToIssueMutation{}
-	input := &githubv4.AddCommentInput{
+	input := githubv4.AddCommentInput{
 		SubjectID: subjectID,
 		Body:      githubv4.String(body),
 	}
@@ -584,7 +589,7 @@ func addCommentGithubIssue(gc *githubv4.Client, subjectID string, body string) (
 
 func editCommentGithubIssue(gc *githubv4.Client, commentID, body string) (string, string, error) {
 	m := &updateIssueCommentMutation{}
-	input := &githubv4.UpdateIssueCommentInput{
+	input := githubv4.UpdateIssueCommentInput{
 		ID:   commentID,
 		Body: githubv4.String(body),
 	}
@@ -606,7 +611,7 @@ func updateGithubIssueStatus(gc *githubv4.Client, id string, status bug.Status)
 		state = githubv4.IssueStateOpen
 	}
 
-	input := &githubv4.UpdateIssueInput{
+	input := githubv4.UpdateIssueInput{
 		ID:    id,
 		State: &state,
 	}
@@ -620,7 +625,7 @@ func updateGithubIssueStatus(gc *githubv4.Client, id string, status bug.Status)
 
 func updateGithubIssueBody(gc *githubv4.Client, id string, body string) error {
 	m := &updateIssueMutation{}
-	input := &githubv4.UpdateIssueInput{
+	input := githubv4.UpdateIssueInput{
 		ID:   id,
 		Body: (*githubv4.String)(&body),
 	}
@@ -634,7 +639,7 @@ func updateGithubIssueBody(gc *githubv4.Client, id string, body string) error {
 
 func updateGithubIssueTitle(gc *githubv4.Client, id, title string) error {
 	m := &updateIssueMutation{}
-	input := &githubv4.UpdateIssueInput{
+	input := githubv4.UpdateIssueInput{
 		ID:    id,
 		Title: (*githubv4.String)(&title),
 	}
@@ -654,7 +659,7 @@ func (ge *githubExporter) updateGithubIssueLabels(gc *githubv4.Client, labelable
 	}
 
 	m := &addLabelsToLabelableMutation{}
-	inputAdd := &githubv4.AddLabelsToLabelableInput{
+	inputAdd := githubv4.AddLabelsToLabelableInput{
 		LabelableID: labelableID,
 		LabelIDs:    addedIDs,
 	}
@@ -670,7 +675,7 @@ func (ge *githubExporter) updateGithubIssueLabels(gc *githubv4.Client, labelable
 	}
 
 	m2 := &removeLabelsFromLabelableMutation{}
-	inputRemove := &githubv4.RemoveLabelsFromLabelableInput{
+	inputRemove := githubv4.RemoveLabelsFromLabelableInput{
 		LabelableID: labelableID,
 		LabelIDs:    removedIDs,
 	}

cache/bug_cache.go 🔗

@@ -260,7 +260,7 @@ func (c *BugCache) SetMetadata(target git.Hash, newMetadata map[string]string) (
 		return nil, err
 	}
 
-	return c.SetMetadataRaw(author, time.Now().Unix(), target, nil)
+	return c.SetMetadataRaw(author, time.Now().Unix(), target, newMetadata)
 }
 
 func (c *BugCache) SetMetadataRaw(author *IdentityCache, unixTime int64, target git.Hash, newMetadata map[string]string) (*bug.SetMetadataOperation, error) {

doc/man/git-bug-bridge-push.1 🔗

@@ -0,0 +1,29 @@
+.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" "" 
+.nh
+.ad l
+
+
+.SH NAME
+.PP
+git\-bug\-bridge\-push \- Push updates.
+
+
+.SH SYNOPSIS
+.PP
+\fBgit\-bug bridge push [<name>] [flags]\fP
+
+
+.SH DESCRIPTION
+.PP
+Push updates.
+
+
+.SH OPTIONS
+.PP
+\fB\-h\fP, \fB\-\-help\fP[=false]
+    help for push
+
+
+.SH SEE ALSO
+.PP
+\fBgit\-bug\-bridge(1)\fP

doc/man/git-bug-bridge.1 🔗

@@ -26,4 +26,4 @@ Configure and use bridges to other bug trackers.
 
 .SH SEE ALSO
 .PP
-\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-pull(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP
+\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-pull(1)\fP, \fBgit\-bug\-bridge\-push(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP

doc/md/git-bug_bridge.md 🔗

@@ -21,5 +21,6 @@ git-bug bridge [flags]
 * [git-bug](git-bug.md)	 - A bug tracker embedded in Git.
 * [git-bug bridge configure](git-bug_bridge_configure.md)	 - Configure a new bridge.
 * [git-bug bridge pull](git-bug_bridge_pull.md)	 - Pull updates.
+* [git-bug bridge push](git-bug_bridge_push.md)	 - Push updates.
 * [git-bug bridge rm](git-bug_bridge_rm.md)	 - Delete a configured bridge.
 

doc/md/git-bug_bridge_push.md 🔗

@@ -0,0 +1,22 @@
+## git-bug bridge push
+
+Push updates.
+
+### Synopsis
+
+Push updates.
+
+```
+git-bug bridge push [<name>] [flags]
+```
+
+### Options
+
+```
+  -h, --help   help for push
+```
+
+### SEE ALSO
+
+* [git-bug bridge](git-bug_bridge.md)	 - Configure and use bridges to other bug trackers.
+

misc/bash_completion/git-bug 🔗

@@ -351,6 +351,26 @@ _git-bug_bridge_pull()
     noun_aliases=()
 }
 
+_git-bug_bridge_push()
+{
+    last_command="git-bug_bridge_push"
+
+    command_aliases=()
+
+    commands=()
+
+    flags=()
+    two_word_flags=()
+    local_nonpersistent_flags=()
+    flags_with_completion=()
+    flags_completion=()
+
+
+    must_have_one_flag=()
+    must_have_one_noun=()
+    noun_aliases=()
+}
+
 _git-bug_bridge_rm()
 {
     last_command="git-bug_bridge_rm"
@@ -380,6 +400,7 @@ _git-bug_bridge()
     commands=()
     commands+=("configure")
     commands+=("pull")
+    commands+=("push")
     commands+=("rm")
 
     flags=()

misc/zsh_completion/git-bug 🔗

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 #compdef _git-bug git-bug
 
 
@@ -394,3 +395,51 @@ function _git-bug_webui {
     '(-p --port)'{-p,--port}'[Port to listen to (default is random)]:'
 }
 
+=======
+#compdef git-bug
+
+_arguments \
+  '1: :->level1' \
+  '2: :->level2' \
+  '3: :_files'
+case $state in
+  level1)
+    case $words[1] in
+      git-bug)
+        _arguments '1: :(add bridge commands comment deselect label ls ls-id ls-label pull push select show status termui title user version webui)'
+      ;;
+      *)
+        _arguments '*: :_files'
+      ;;
+    esac
+  ;;
+  level2)
+    case $words[2] in
+      bridge)
+        _arguments '2: :(configure pull push rm)'
+      ;;
+      comment)
+        _arguments '2: :(add)'
+      ;;
+      label)
+        _arguments '2: :(add rm)'
+      ;;
+      status)
+        _arguments '2: :(close open)'
+      ;;
+      title)
+        _arguments '2: :(edit)'
+      ;;
+      user)
+        _arguments '2: :(adopt create ls)'
+      ;;
+      *)
+        _arguments '*: :_files'
+      ;;
+    esac
+  ;;
+  *)
+    _arguments '*: :_files'
+  ;;
+esac
+>>>>>>> 3daac46... update man docs and completion scripts