Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support edit functionality on mrs, issues, and snippets #76

Closed
zaquestion opened this issue Dec 19, 2017 · 6 comments
Closed

Support edit functionality on mrs, issues, and snippets #76

zaquestion opened this issue Dec 19, 2017 · 6 comments

Comments

@zaquestion
Copy link
Owner

Wondering if this should be a edit sub command or a flag --amend (like git)

Want to support setting/updating properties without having to edit the message. The flag approach would make sense to use --no-edit. Not sure the best choice for the sub command route...

That said, leaning towards the sub command to be consistent with other commands, and optionally support --amend as the flag off the parent command.

@cuthix
Copy link

cuthix commented Jun 5, 2018

I very often just need change text or tick/untick part of issue, so would be nice to have command/flag to edit issue text :)

@claytonrcarter
Copy link
Collaborator

@zaquestion I'm tinkering with this and would like some feedback on the behavior and and flag naming. I'm aiming for parity/familiarity with the various lab ... create commands, i.e. title/description/labels/assignees. Here's the help text so far:

$ ./lab issue edit -h
Edit or update an issue

Usage:
  lab issue edit [remote] <id> [flags]

Aliases:
  edit, update

Flags:
  -a, --assign strings     Add an assignee by username
      --edit               Open the issue in an editor (default if no other flags given)
  -h, --help               help for edit
  -l, --label strings      Add the given label(s) to the issue
  -m, --message strings    Use the given <msg>; multiple -m are concatenated as separate paragraphs
  -t, --title string       Set the issue title
  -A, --unassign strings   Remove an assigne by username
  -L, --unlabel strings    Remove the given label(s) from the issue

Specific Questions

  1. I wanted to add a flag to just change the title, hence --title, but this seems to beg for --description flags, too. How would something like that interact with the --message flags (which are standard on lab issue create, lab issue note, lab mr create, etc). Adding --description would be more declarative, which might be appropriate for an edit command, but it could be confusing if --message is left in place. On the other hand, if --message is removed, the syntax would break from the create commands, which doesn't sound great either.
  2. Do the capital shorthands for unassigned and unlabel sound OK?

Usage Examples

Edit issue in editor: lab issue edit <id>
Only update issue title: lab issue edit <id> -t "new title" or: lab issue edit <id> -m "new title"
Only add label to issue: lab issue edit <id> -l newlabel
Add label to issue and edit title/description in editor: lab issue edit <id> -l newlabel --edit

@zaquestion
Copy link
Owner Author

  1. Leaning towards just using the -m notation, as in lab issue edit <id> -m "new title" -m "new description" -- I think it makes sense to not update the description if a second -m isn't sent. This seems intuitive to me, but I'd call it out in the docs. Likewise it seems like we should only open the editor if no flags are passed, vs supporting a --edit flag. In your last example this would mean 2 separate commands, which seems reasonable to me.

  2. Seems weird at a glance. How does the API enforce these? Off the cuff I'm thinking we should just use the same flags, but have them operate as a toggle if thats how the API works anyways. Otherwise, perhaps we just shouldn't have shorthands for those flags.

@claytonrcarter
Copy link
Collaborator

Aaannnddd ... I had no idea that the -m flags and their behavior was taken directly from git. 🤦‍♂️ OK, so I'll skip --title and --edit, and make sure that the editor only opens if no flags are passed.

As for unlabel and unassign, as far as I can tell, the API doesn't support a specific "unlabel" action; it seems to be "all or nothing", so if you want to remove a label, you have to send the whole list of labels currently on the issue w/o the one you want to remove. The same for assignees. From https://docs.gitlab.com/ce/api/issues.html#edit-issue:

assignee_ids - The ID of the user(s) to assign the issue to. Set to 0 or provide an empty value to unassign all assignees.
labels - Comma-separated label names for an issue. Set to an empty string to unassign all labels.

In seeking shorthands for those flags, I was aiming for the "relabel" or "reassign" use case, where you need to remove one label/assignee and add another. -l newlabel -L oldlabel seemed more convenient than --label newlabel --unlabel oldlabel, though not by much I guess, and autocompletion can help quite a bit.

I'm skeptical of a toggle; it seems like it would make it very easy to make mistakes. You could run the same command with the same flags twice and get two different results. If we go that direction, I would suggest we change the flag name to toggle-label (and toggle-assignee).

@zaquestion
Copy link
Owner Author

Yeah, just dropping the short hand and using separate flags seems better than toggling.

@bmeneg
Copy link
Collaborator

bmeneg commented Jun 15, 2021

Edition for MRs and Issue is now available. Snippets aren't yet, but we can handle that in a separate issue re-using the code already existent for both MRs and Issues. I'm going to close this issue here.

@bmeneg bmeneg closed this as completed Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants