-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
feat: include local dirty changes by default. fixes #184 #520
Conversation
So, just to be clear: this change creates the wip commits in a temporary copy/clone, right? Not in the original template repository? If it does so in the original: Let me know what you all think (and correct me if I'm wrong!) |
I originally was creating the commit in the original template repository because that was easier, but I agree that it is too intrusive. The current code modifies |
Docs failure is because mkdocs-autorefs 0.3.1 was installed, while mkdocstrings 0.17.0 was not. I should probably have tagged mkdocs-autorefs 0.4.0 to prevent that. Or better yet, upper bounds could be removed on Copier's dependencies 😛 |
Got it—should I just add |
I wasn't clear: mkdocstrings should be updated (up to 0.17.0), not mkdocs-autorefs. But it should probably be done in another PR (it's very easy, just manually update mkdocstrings accepted range in pyproject.toml and regen the lock file with |
960455b
to
3fe1f42
Compare
I saw this was fixed in #518, so I just rebased instead. |
Oh yes, good catch. |
Codecov Report
@@ Coverage Diff @@
## master #520 +/- ##
==========================================
- Coverage 96.45% 96.32% -0.14%
==========================================
Files 40 41 +1
Lines 2623 2693 +70
==========================================
+ Hits 2530 2594 +64
- Misses 93 99 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Hi @sabard! Welcome to Copier 😊
This PR is very nice already. There are some improvements to do below, but overall it's almost ready to merge.
Thank you very much for your contribution!
PS: Please make that CI happy 😉
3fe1f42
to
15177a8
Compare
Removed Python 3.7 incompatible Should be ready for another CI run. |
copier/vcs.py
Outdated
if os.path.isdir(s): | ||
copytree(s, d) | ||
else: | ||
copy2(s, d) |
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.
Looking closer to the algorithm, it's not much efficient. Luckily it's very easy to improve. It should:
- clone
cd
intourl
.git diff --binary HEAD
to get a patch.cd
into new clonegit apply
the patch- wip commit.
This way you don't have to create yet aother clone just to add 1 extra commit. Besides, you avoid copying manually instead of using git clone (which is safer and more efficient too).
P,S. please avoid naming variables with a single letter. Makes the code harder to understand.
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.
This turned out to be not so simple for a few reasons:
git diff
does not, by default, give a diff of the untracked files (of interested here doing a dirty copy)HEAD
might not exist (e.g.,git init
was just run)
That said, I was able to get something closer to what you are asking for working by using git diff --no-index
and then excluding */.git/*
on the apply. This will of course copy over other unwanted files to the temporary clone directory, but they shouldn't make it into the subdirectory since they will be in the clone's .gitignore. I think this is arguably just as inefficient in the worst-case (large .gitignored file getting needlessly copied).
I tried getting something like git --git-dir=<clone_dst>/.git --work-tree=<template_src> diff HEAD
SO source to work to no avail. Seems that anytime git-diff
is used without --no-index
it ignores untracked files.
Need to make a couple fixes for CI still, but pushed latest changes to avoid losing progress.
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.
AFAIK git stash
works both with staged and untracked files. Have you tried with it?
Please also add a note in the changelog. |
The most recent commit should probably pass CI. However: I'm seeing |
ae3470f
to
49e4fbd
Compare
After some thinking, I figured it would be a better solution to create a new |
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.
Looks much nicer now!
Just remove that leftover line and one question to merge!
Thanks again, great job!
|
||
with local.cwd(location): | ||
git("checkout", ref or "HEAD") | ||
git("submodule", "update", "--checkout", "--init", "--recursive", "--force") |
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've got the feeling that this block should be done before importing the ditty changes. However, if the test goes green I guess I'm just wrong.
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 think it shouldn't matter if it runs before or after. But if there is no HEAD in the case of a recently intialized repo, then this fails and would need to be called after as well. I also realized that specifying ref
means that dirty changes won't be considered and so added that to the dirty checking logic.
Any tips for figuring out what's wrong with CI on windows? I cloned and ran the tests on my windows box and they passed, so having trouble replicating to get more info on the error. EDIT: tried a |
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.
Looks good! Just make it green to merge.
Thanks.
A quick attempt at implementing the changes described in this comment.
I made this the default behavior, but would be happy to add a flag for this behavior and maintain the current default.
Also, think this will have to rebase off of #519 to pass CI