-
Notifications
You must be signed in to change notification settings - Fork 511
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
update to allow removing pending changes #856
Conversation
Seems like the |
} | ||
|
||
func (t *tufCommander) AddToCommand(cmd *cobra.Command) { | ||
cmdTUFInit := cmdTUFInitTemplate.ToCommand(t.tufInit) | ||
cmdTUFInit.Flags().StringVar(&t.rootKey, "rootkey", "", "Root key to initialize the repository with") | ||
cmd.AddCommand(cmdTUFInit) | ||
|
||
cmd.AddCommand(cmdTUFStatusTemplate.ToCommand(t.tufStatus)) | ||
cmdStatus := cmdTUFStatusTemplate.ToCommand(t.tufStatus) | ||
cmdStatus.Flags().IntSliceVarP(&t.changes, "unstage", "u", nil, "Numbers of changes to delete, as show in status list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/show/shown
took this out for a spin and the functionality is great! Just a couple of small nits, can't wait for when tests are ready :) |
if err != nil { | ||
return err | ||
} | ||
sort.Sort(fileChanges(fileInfos)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we factor out the first few lines of this function and List
into a helper for getting back a sorted list of []os.FileInfo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just make list and the iterator getFileNames
return in a deterministic (sorted) order
d98d195
to
677cb1f
Compare
Signed-off-by: David Lawrence <[email protected]> (github: endophage)
…change can't be applied before aborting Signed-off-by: David Lawrence <[email protected]> (github: endophage)
@@ -21,6 +21,24 @@ func (cl *memChangelist) Add(c Change) error { | |||
return nil | |||
} | |||
|
|||
// Remove deletes the changes found at the given indices | |||
func (cl *memChangelist) Remove(idxs []int) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test for this method? I think the cmd
functions only use file changelists which is why it isn't covered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Signed-off-by: David Lawrence <[email protected]> (github: endophage)
677cb1f
to
57379e8
Compare
LGTM pending CI |
if len(cl.List()) == 0 { | ||
cmd.Printf("No unpublished changes for %s\n", gun) | ||
return nil | ||
} | ||
|
||
cmd.Printf("Unpublished changes for %s:\n\n", gun) | ||
cmd.Printf("%-10s%-10s%-12s%s\n", "action", "scope", "type", "path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for fixing this formatting! It looks much nicer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big fan of tabwriter now that I've discovered it :-)
LGTM pending CI! |
Needs tests
Partially addresses #596
Adds
--reset
and--unstage
flags tonotary status
.reset
removes all pending changes for the GUN,unstage
allows specific changes to be removed based on their # as shown innotary status
Signed-off-by: David Lawrence [email protected] (github: endophage)