mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: seed issue create from --template, edit and delete inline review comments, explain workflow run refs (follow gh)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
9 files changed
+122
-21
No files matched your search
@@ -61,6 +61,10 @@ func issueCommandPath(cmd *cobra.Command) string {
|
||||
|
||||
// commentName names a comment in messages: "comment 81 on alice/x#1".
|
||||
func commentName(t target, comment services.Comment) string {
|
||||
if comment.IssueNumber == 0 {
|
||||
// Inline review comments cannot be fetched, so their discussion is unknown.
|
||||
return fmt.Sprintf("comment %d on %s", comment.ID, t.Repo)
|
||||
}
|
||||
return fmt.Sprintf("comment %d on %s#%d", comment.ID, t.Repo, comment.IssueNumber)
|
||||
}
|
||||
|
||||
@@ -159,8 +163,10 @@ func lastComment(cmd *cobra.Command, t target, n int64) (services.Comment, error
|
||||
}
|
||||
|
||||
// comment returns the comment that the ID argument names, which a command of kind may change: pr
|
||||
// commands refuse comments on issues.
|
||||
func (a *application) comment(cmd *cobra.Command, arg string, kind refKind) (target, services.Comment, error) {
|
||||
// commands refuse comments on issues. With changing set, as for edit and delete, a comment that
|
||||
// cannot be fetched, such as an inline review comment, is returned by its ID alone: the edit and
|
||||
// delete endpoints accept it.
|
||||
func (a *application) comment(cmd *cobra.Command, arg string, kind refKind, changing bool) (target, services.Comment, error) {
|
||||
id, err := number(arg)
|
||||
if err != nil {
|
||||
return target{}, services.Comment{}, err
|
||||
@@ -170,6 +176,9 @@ func (a *application) comment(cmd *cobra.Command, arg string, kind refKind) (tar
|
||||
return t, services.Comment{}, err
|
||||
}
|
||||
current, err := (services.Comments{Client: t.client, Repository: t.Repo}).View(cmd.Context(), id)
|
||||
if notPlain := (services.NotPlainCommentError{}); changing && errors.As(err, ¬Plain) {
|
||||
return t, services.Comment{ID: id}, nil
|
||||
}
|
||||
if err == nil && kind == pullRef && !current.Pull {
|
||||
err = fmt.Errorf("comment %d in %s is on an issue, not a pull request; use %s %d", id, t.Repo, issueCommandPath(cmd), id)
|
||||
}
|
||||
@@ -338,7 +347,7 @@ $ tea %[1]s comment list %[2]s --json id,author,body`, words.group, words.exampl
|
||||
list.ValidArgsFunction = a.completeDiscussions(kind)
|
||||
|
||||
view := &cobra.Command{Use: "view <comment-id>", Short: "View a comment", Example: fmt.Sprintf("$ tea %s comment view 81", words.group), Args: argsExact(1), RunE: func(cmd *cobra.Command, args []string) error {
|
||||
t, comment, err := a.comment(cmd, args[0], kind)
|
||||
t, comment, err := a.comment(cmd, args[0], kind, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -366,7 +375,7 @@ $ tea %[1]s comment edit 81`, words.group), Args: argsExact(1), RunE: func(cmd *
|
||||
if err := editFlags.validate(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
t, comment, err := a.comment(cmd, args[0], kind)
|
||||
t, comment, err := a.comment(cmd, args[0], kind, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -375,7 +384,7 @@ $ tea %[1]s comment edit 81`, words.group), Args: argsExact(1), RunE: func(cmd *
|
||||
editFlags.register(edit)
|
||||
|
||||
remove := &cobra.Command{Use: "delete <comment-id>", Short: "Delete a comment", Example: fmt.Sprintf("$ tea %s comment delete 81 --yes", words.group), Annotations: map[string]string{"tea.text": "comment deletion does not return a resource", "tea.confirm": "true"}, Args: argsExact(1), RunE: func(cmd *cobra.Command, args []string) error {
|
||||
t, comment, err := a.comment(cmd, args[0], kind)
|
||||
t, comment, err := a.comment(cmd, args[0], kind, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user