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

New feature: add a new policy for fixing clashes #810

Merged
merged 1 commit into from
Dec 18, 2016

Conversation

iblislin
Copy link

Hi,
I add an new command line option for drive clashes. Let user switch the policy between rename (the original) and trash. When I encounter the clashes, I always trash it then re-push again. Hope this also useful for other user. And the simple usage is documented in the commit message.

To be honest, I never wrote any line of golang code before I decide to add this feature. I just browsed the golang tutorial at the last Sunday afternoon. Please read my code carefully and comment. :)

Copy link
Owner

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor changes requested, code looks good. Could we also document this in the README.md, if possible?

type FixClashesMode uint8

const (
FixClashesRename FixClashesMode = iota
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this 1 + iota, so that when we can catch the
zero/uninitialized value, and reject it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @ 9d078d9


func autoTrashClashes(g *Commands, clashes []*Change) error {
for _, c := range clashes {
// make c.Op() == OpDelete
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just update this comment to

// Let's coerce this change to a deletion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @ f7a68ea

}

if g.opts.canPrompt() {
g.log.Logln("Some clashes found, trashes them ?")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace
trashes them ?
with
trash them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @ 04dcf5e

@odeke-em
Copy link
Owner

Hello there @iblis17, thank you for the PR and welcome to drive!

This is awesome, your first Go code looks great!
I've made 3 comments for minor feedback otherwise we are in good shape.

@iblislin
Copy link
Author

README.md updated @ 283066c

@odeke-em
Copy link
Owner

Dope! One last thing, let's squash all these commits into one and then I'll merge it in. Just in
case you need to

$ git rebase -i head~6

and when prompted for the message, let's set it to something like this

clashes: add trash and no-prompt to deal with clashes

Added trash and no-prompt to clash. The default is `rename` but
in some cases it is convenient to trash duplicates. This PR makes
that possible.

Thank you!

Added trash and no-prompt to clash. The default is `rename` but
in some cases it is convenient to trash duplicates. This PR makes
that possible.

New cli option for `drive clashes`:
    $ drive clashes -fix -fix-mode trash
@iblislin
Copy link
Author

Rebased !

@odeke-em
Copy link
Owner

Thank you, LGTM!

@odeke-em odeke-em merged commit fa3d326 into odeke-em:master Dec 18, 2016
@odeke-em odeke-em added this to the v0.3.9 milestone Dec 18, 2016
@jpambrun
Copy link

This change is confusing when using "drive clashes -fix -fix-mode trash [remote folder]" since is trashes both files. When doing so, I expected the newest file to be kept. Deleting both files certainly fixed the clash, but so would "rm -Rf" 😉.

@iblislin
Copy link
Author

@jpambrun Trashing them all and re-pushing is just my habit. Feel free to rename it and add the feature you want.


Maybe I should notice user that it will trash both of new and old files on README.md

iblislin added a commit to iblislin/drive that referenced this pull request Dec 19, 2016
iblislin added a commit to iblislin/drive that referenced this pull request Dec 19, 2016
iblislin added a commit to iblislin/drive that referenced this pull request Dec 19, 2016
iblislin added a commit to iblislin/drive that referenced this pull request Dec 19, 2016
@jpambrun
Copy link

What is the purpose of this? It does not make a lot of sense.

Especially since in my case, I had no local copy.

@iblislin
Copy link
Author

iblislin commented Dec 20, 2016

Those are just different use cases. And I think there are no correct one or wrong one.
If this feature is not fitting your requirement. what about adding another function or option, contributing the code back, and make drive better!

If you really want that feature and do not want to write code, please open a feature request. I can push it into my TODO stack... Maybe I will make it at some Sunday afternoon.

@jpambrun
Copy link

I'm sorry if that came out a bit harsh; that was not the intent. I don't feel very strongly about this issue/feature and the proposed changes make it clear that it is a destructive operation.

Personally, I wouldn't make any destructive operations the default behavior for this type of application. I wanted to fix clashes and I issued "drive clashes -fix -fix-mode trash" on in a clean ~/gdrive folder thinking it would fix clashes based on the documentation.

Anyway, I appreciate your contribution.

@iblislin
Copy link
Author

Personally, I wouldn't make any destructive operations the default behavior for this type of application. I wanted to fix clashes and I issued "drive clashes -fix -fix-mode trash" on in a clean ~/gdrive folder thinking it would fix clashes based on the documentation.

Hearing a different need is not a bad thing, and it's the source of innovation of open source. :)

I will try to add a new policy called trash-old (or something like that), if I get free time.

@jpambrun
Copy link

jpambrun commented Dec 20, 2016 via email

@iblislin
Copy link
Author

ok, I got it. (I think I am quite used to fix them via C4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants