mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
commands: add git bug comment add
to add a comment
This commit is contained in:
parent
bfb5e96aab
commit
6cdc6c087e
85
commands/comment_add.go
Normal file
85
commands/comment_add.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/MichaelMure/git-bug/cache"
|
||||||
|
"github.com/MichaelMure/git-bug/input"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
commentAddMessageFile string
|
||||||
|
commentAddMessage string
|
||||||
|
)
|
||||||
|
|
||||||
|
func runCommentAdd(cmd *cobra.Command, args []string) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if len(args) > 1 {
|
||||||
|
return errors.New("Only one bug id is supported")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errors.New("You must provide a bug id")
|
||||||
|
}
|
||||||
|
|
||||||
|
backend, err := cache.NewRepoCache(repo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer backend.Close()
|
||||||
|
|
||||||
|
prefix := args[0]
|
||||||
|
|
||||||
|
if commentAddMessageFile != "" && commentAddMessage == "" {
|
||||||
|
commentAddMessage, err = input.FromFile(commentAddMessageFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if commentAddMessage == "" {
|
||||||
|
commentAddMessage, err = input.BugCommentEditorInput(backend.Repository())
|
||||||
|
if err == input.ErrEmptyMessage {
|
||||||
|
fmt.Println("Empty message, aborting.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := backend.ResolveBugPrefix(prefix)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = b.AddComment(commentAddMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.Commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
var commentAddCmd = &cobra.Command{
|
||||||
|
Use: "add <id>",
|
||||||
|
Short: "Add a new comment to a bug",
|
||||||
|
RunE: runCommentAdd,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
commentCmd.AddCommand(commentAddCmd)
|
||||||
|
|
||||||
|
commentCmd.Flags().SortFlags = false
|
||||||
|
|
||||||
|
commentCmd.Flags().StringVarP(&commentAddMessageFile, "file", "F", "",
|
||||||
|
"Take the message from the given file. Use - to read the message from the standard input",
|
||||||
|
)
|
||||||
|
|
||||||
|
commentCmd.Flags().StringVarP(&commentAddMessage, "message", "m", "",
|
||||||
|
"Provide the new message from the command line",
|
||||||
|
)
|
||||||
|
}
|
41
doc/man/git-bug-add.1
Normal file
41
doc/man/git-bug-add.1
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" ""
|
||||||
|
.nh
|
||||||
|
.ad l
|
||||||
|
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
.PP
|
||||||
|
git\-bug\-add \- Create a new bug
|
||||||
|
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.PP
|
||||||
|
\fBgit\-bug add [flags]\fP
|
||||||
|
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.PP
|
||||||
|
Create a new bug
|
||||||
|
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.PP
|
||||||
|
\fB\-t\fP, \fB\-\-title\fP=""
|
||||||
|
Provide a title to describe the issue
|
||||||
|
|
||||||
|
.PP
|
||||||
|
\fB\-m\fP, \fB\-\-message\fP=""
|
||||||
|
Provide a message to describe the issue
|
||||||
|
|
||||||
|
.PP
|
||||||
|
\fB\-F\fP, \fB\-\-file\fP=""
|
||||||
|
Take the message from the given file. Use \- to read the message from the standard input
|
||||||
|
|
||||||
|
.PP
|
||||||
|
\fB\-h\fP, \fB\-\-help\fP[=false]
|
||||||
|
help for add
|
||||||
|
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.PP
|
||||||
|
\fBgit\-bug(1)\fP
|
29
doc/man/git-bug-comment-add.1
Normal file
29
doc/man/git-bug-comment-add.1
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" ""
|
||||||
|
.nh
|
||||||
|
.ad l
|
||||||
|
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
.PP
|
||||||
|
git\-bug\-comment\-add \- Add a new comment to a bug
|
||||||
|
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.PP
|
||||||
|
\fBgit\-bug comment add <id> [flags]\fP
|
||||||
|
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.PP
|
||||||
|
Add a new comment to a bug
|
||||||
|
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.PP
|
||||||
|
\fB\-h\fP, \fB\-\-help\fP[=false]
|
||||||
|
help for add
|
||||||
|
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.PP
|
||||||
|
\fBgit\-bug\-comment(1)\fP
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.PP
|
.PP
|
||||||
git\-bug\-comment \- Add a new comment to a bug
|
git\-bug\-comment \- Show a bug's comments
|
||||||
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -15,7 +15,7 @@ git\-bug\-comment \- Add a new comment to a bug
|
|||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
Add a new comment to a bug
|
Show a bug's comments
|
||||||
|
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
@ -34,4 +34,4 @@ Add a new comment to a bug
|
|||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.PP
|
.PP
|
||||||
\fBgit\-bug(1)\fP
|
\fBgit\-bug(1)\fP, \fBgit\-bug\-comment\-add(1)\fP
|
||||||
|
@ -29,4 +29,4 @@ It use the same internal storage so it doesn't pollute your project. As you woul
|
|||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.PP
|
.PP
|
||||||
\fBgit\-bug\-close(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-new(1)\fP, \fBgit\-bug\-open(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-webui(1)\fP
|
\fBgit\-bug\-add(1)\fP, \fBgit\-bug\-close(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-open(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-webui(1)\fP
|
||||||
|
@ -20,12 +20,12 @@ git-bug [flags]
|
|||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [git-bug add](git-bug_add.md) - Create a new bug
|
||||||
* [git-bug close](git-bug_close.md) - Mark the bug as closed
|
* [git-bug close](git-bug_close.md) - Mark the bug as closed
|
||||||
* [git-bug commands](git-bug_commands.md) - Display available commands
|
* [git-bug commands](git-bug_commands.md) - Display available commands
|
||||||
* [git-bug comment](git-bug_comment.md) - Add a new comment to a bug
|
* [git-bug comment](git-bug_comment.md) - Show a bug's comments
|
||||||
* [git-bug label](git-bug_label.md) - Manipulate bug's label
|
* [git-bug label](git-bug_label.md) - Manipulate bug's label
|
||||||
* [git-bug ls](git-bug_ls.md) - List bugs
|
* [git-bug ls](git-bug_ls.md) - List bugs
|
||||||
* [git-bug new](git-bug_new.md) - Create a new bug
|
|
||||||
* [git-bug open](git-bug_open.md) - Mark the bug as open
|
* [git-bug open](git-bug_open.md) - Mark the bug as open
|
||||||
* [git-bug pull](git-bug_pull.md) - Pull bugs update from a git remote
|
* [git-bug pull](git-bug_pull.md) - Pull bugs update from a git remote
|
||||||
* [git-bug push](git-bug_push.md) - Push bugs update to a git remote
|
* [git-bug push](git-bug_push.md) - Push bugs update to a git remote
|
||||||
|
25
doc/md/git-bug_add.md
Normal file
25
doc/md/git-bug_add.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
## git-bug add
|
||||||
|
|
||||||
|
Create a new bug
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Create a new bug
|
||||||
|
|
||||||
|
```
|
||||||
|
git-bug add [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-t, --title string Provide a title to describe the issue
|
||||||
|
-m, --message string Provide a message to describe the issue
|
||||||
|
-F, --file string Take the message from the given file. Use - to read the message from the standard input
|
||||||
|
-h, --help help for add
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [git-bug](git-bug.md) - A bugtracker embedded in Git
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
## git-bug comment
|
## git-bug comment
|
||||||
|
|
||||||
Add a new comment to a bug
|
Show a bug's comments
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Add a new comment to a bug
|
Show a bug's comments
|
||||||
|
|
||||||
```
|
```
|
||||||
git-bug comment <id> [flags]
|
git-bug comment <id> [flags]
|
||||||
@ -21,4 +21,5 @@ git-bug comment <id> [flags]
|
|||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [git-bug](git-bug.md) - A bugtracker embedded in Git
|
* [git-bug](git-bug.md) - A bugtracker embedded in Git
|
||||||
|
* [git-bug comment add](git-bug_comment_add.md) - Add a new comment to a bug
|
||||||
|
|
||||||
|
22
doc/md/git-bug_comment_add.md
Normal file
22
doc/md/git-bug_comment_add.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## git-bug comment add
|
||||||
|
|
||||||
|
Add a new comment to a bug
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Add a new comment to a bug
|
||||||
|
|
||||||
|
```
|
||||||
|
git-bug comment add <id> [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for add
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [git-bug comment](git-bug_comment.md) - Show a bug's comments
|
||||||
|
|
@ -248,6 +248,35 @@ _git_bug() {
|
|||||||
__start_git-bug "$@"
|
__start_git-bug "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git-bug_add()
|
||||||
|
{
|
||||||
|
last_command="git-bug_add"
|
||||||
|
|
||||||
|
command_aliases=()
|
||||||
|
|
||||||
|
commands=()
|
||||||
|
|
||||||
|
flags=()
|
||||||
|
two_word_flags=()
|
||||||
|
local_nonpersistent_flags=()
|
||||||
|
flags_with_completion=()
|
||||||
|
flags_completion=()
|
||||||
|
|
||||||
|
flags+=("--title=")
|
||||||
|
two_word_flags+=("-t")
|
||||||
|
local_nonpersistent_flags+=("--title=")
|
||||||
|
flags+=("--message=")
|
||||||
|
two_word_flags+=("-m")
|
||||||
|
local_nonpersistent_flags+=("--message=")
|
||||||
|
flags+=("--file=")
|
||||||
|
two_word_flags+=("-F")
|
||||||
|
local_nonpersistent_flags+=("--file=")
|
||||||
|
|
||||||
|
must_have_one_flag=()
|
||||||
|
must_have_one_noun=()
|
||||||
|
noun_aliases=()
|
||||||
|
}
|
||||||
|
|
||||||
_git-bug_close()
|
_git-bug_close()
|
||||||
{
|
{
|
||||||
last_command="git-bug_close"
|
last_command="git-bug_close"
|
||||||
@ -291,6 +320,26 @@ _git-bug_commands()
|
|||||||
noun_aliases=()
|
noun_aliases=()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git-bug_comment_add()
|
||||||
|
{
|
||||||
|
last_command="git-bug_comment_add"
|
||||||
|
|
||||||
|
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_comment()
|
_git-bug_comment()
|
||||||
{
|
{
|
||||||
last_command="git-bug_comment"
|
last_command="git-bug_comment"
|
||||||
@ -298,6 +347,7 @@ _git-bug_comment()
|
|||||||
command_aliases=()
|
command_aliases=()
|
||||||
|
|
||||||
commands=()
|
commands=()
|
||||||
|
commands+=("add")
|
||||||
|
|
||||||
flags=()
|
flags=()
|
||||||
two_word_flags=()
|
two_word_flags=()
|
||||||
@ -378,35 +428,6 @@ _git-bug_ls()
|
|||||||
noun_aliases=()
|
noun_aliases=()
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-bug_new()
|
|
||||||
{
|
|
||||||
last_command="git-bug_new"
|
|
||||||
|
|
||||||
command_aliases=()
|
|
||||||
|
|
||||||
commands=()
|
|
||||||
|
|
||||||
flags=()
|
|
||||||
two_word_flags=()
|
|
||||||
local_nonpersistent_flags=()
|
|
||||||
flags_with_completion=()
|
|
||||||
flags_completion=()
|
|
||||||
|
|
||||||
flags+=("--title=")
|
|
||||||
two_word_flags+=("-t")
|
|
||||||
local_nonpersistent_flags+=("--title=")
|
|
||||||
flags+=("--message=")
|
|
||||||
two_word_flags+=("-m")
|
|
||||||
local_nonpersistent_flags+=("--message=")
|
|
||||||
flags+=("--file=")
|
|
||||||
two_word_flags+=("-F")
|
|
||||||
local_nonpersistent_flags+=("--file=")
|
|
||||||
|
|
||||||
must_have_one_flag=()
|
|
||||||
must_have_one_noun=()
|
|
||||||
noun_aliases=()
|
|
||||||
}
|
|
||||||
|
|
||||||
_git-bug_open()
|
_git-bug_open()
|
||||||
{
|
{
|
||||||
last_command="git-bug_open"
|
last_command="git-bug_open"
|
||||||
@ -537,12 +558,12 @@ _git-bug_root_command()
|
|||||||
command_aliases=()
|
command_aliases=()
|
||||||
|
|
||||||
commands=()
|
commands=()
|
||||||
|
commands+=("add")
|
||||||
commands+=("close")
|
commands+=("close")
|
||||||
commands+=("commands")
|
commands+=("commands")
|
||||||
commands+=("comment")
|
commands+=("comment")
|
||||||
commands+=("label")
|
commands+=("label")
|
||||||
commands+=("ls")
|
commands+=("ls")
|
||||||
commands+=("new")
|
|
||||||
commands+=("open")
|
commands+=("open")
|
||||||
commands+=("pull")
|
commands+=("pull")
|
||||||
commands+=("push")
|
commands+=("push")
|
||||||
|
@ -2,12 +2,23 @@
|
|||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :->level1' \
|
'1: :->level1' \
|
||||||
'2: :_files'
|
'2: :->level2' \
|
||||||
|
'3: :_files'
|
||||||
case $state in
|
case $state in
|
||||||
level1)
|
level1)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
git-bug)
|
git-bug)
|
||||||
_arguments '1: :(close commands comment label ls new open pull push show termui webui)'
|
_arguments '1: :(add close commands comment label ls open pull push show termui webui)'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_arguments '*: :_files'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
level2)
|
||||||
|
case $words[2] in
|
||||||
|
comment)
|
||||||
|
_arguments '2: :(add)'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_arguments '*: :_files'
|
_arguments '*: :_files'
|
||||||
|
Loading…
Reference in New Issue
Block a user