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 wrapped clone in current directory #1478

Merged
merged 3 commits into from
Aug 23, 2016
Merged

Conversation

ttaylorr
Copy link
Contributor

This PR supports cloning into the current directory, ".", a-la:

$ git lfs clone git@github.com:foo/bar.git .

Previously, this was broken because an invocation to the git-lfs clone command would create a localstorage directory due to a call to the localstorage.ResolveDirs function causing both of these files to be created. The presence of those files violated a git-clone invariant that the clone target must be empty. That source of that call is from the init() function in the lfs package, here.

In e447be2, I removed that call, and instead replaced it with a PreRun hook on all of our commands, except clone. PreRun hooks, as dictated by the cobra package will run before the actual Run function of the command.

In a further PR, we should definitely take a look at which commands actually need to have the localstorage stuff initialized.

/cc @technoweenie @rubyist @sinbad for review
/cc @tarka #1431 for a heads-up

Run: cleanCommand,
Use: "clean",
Run: cleanCommand,
PreRun: resolveLocalStorage,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could remove all the duplication of setting PreRun (and potentially forgetting to include it) by standardising on a wrapper function like NewLfsCommand("clean", cleanCommand) or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I am going to leave this as-is, and only give the PreRun option to commands that need it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that all of them except clone? I expect all new commands will need it too, would be easier to remember with a utility function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would rather be explicit about which commands are using it up front. If it ends up being the majority, then perhaps it makes sense to add a helper function, but not now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there are a few commands that don't need it, like env, but I'd bet that the majority of commands will need it.

@sinbad
Copy link
Contributor

sinbad commented Aug 23, 2016

That's a fascinating edge case 😄

👍 from me

@ttaylorr ttaylorr merged commit 4d516f0 into master Aug 23, 2016
@ttaylorr ttaylorr deleted the clone-in-current-directory branch August 23, 2016 15:09
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Sep 10, 2024
In commit 365d615 of PR git-lfs#1478 a
pair of tests in what is now our t/t-clone.sh test script were enhanced
to check that the "git lfs clone" command did not create a directory
named "lfs" within the top level ofa cloned repository's working tree,
as the "lfs" directory should instead be created within the ".git"
directory.

This check has since been replicated in a number of other tests
in the t/t-clone.sh script, but not all of them, so we add this
check in the relevant sections of the tests where it is not yet
performed.  We also adjust one check which dates from commit
365d615 to use the same -e shell
test as all the other checks, rather than the -f test.

These changes are not especially important, but in conjunction with
the revisions we have made in other commits in this PR, will help
synchonize the tests in the t/t-clone.sh script so they are more
consistent and complete.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Sep 15, 2024
In commit 365d615 of PR git-lfs#1478 a
pair of tests in what is now our t/t-clone.sh test script were enhanced
to check that the "git lfs clone" command did not create a directory
named "lfs" within the top level ofa cloned repository's working tree,
as the "lfs" directory should instead be created within the ".git"
directory.

This check has since been replicated in a number of other tests
in the t/t-clone.sh script, but not all of them, so we add this
check in the relevant sections of the tests where it is not yet
performed.  We also adjust one check which dates from commit
365d615 to use the same -e shell
test as all the other checks, rather than the -f test.

These changes are not especially important, but in conjunction with
the revisions we have made in other commits in this PR, will help
synchonize the tests in the t/t-clone.sh script so they are more
consistent and complete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants