This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 540
Remove empty dirs when cleaning with Dir opt. #933
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@onodera-punpun - Could you check if this fix works for you? |
@ajnavarro - done. I've added a test to check if empty dirs are cleaned, as well. |
ajnavarro
approved these changes
Aug 27, 2018
jfontan
approved these changes
Aug 27, 2018
mcuadros
suggested changes
Aug 29, 2018
worktree.go
Outdated
// skip the path. | ||
if relativePath != filepath.Base(relativePath) && !opts.Dir { | ||
continue | ||
var clean func(string, []os.FileInfo) 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 you move this function to a member function called doClean
mcuadros
reviewed
Aug 29, 2018
worktree.go
Outdated
if status.Worktree == Untracked { | ||
absPath := filepath.Join(w.Filesystem.Root(), relativePath) | ||
if err := os.Remove(absPath); err != nil { | ||
if opts.Dir { |
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.
also will be nice move this code to a function something like doCleanDirectories
Signed-off-by: kuba-- <[email protected]>
Signed-off-by: kuba-- <[email protected]>
@mcuadros - PR refined and rebased. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: kuba-- [email protected]
Fixes #895
When
CleanOptions.Dir
is set ontrue
then an empty dir (with subdirs) could be removed (this is whatgit clean -f -d .
does).