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 updating a subproject when it isn't in the root of the git repo #451

Closed
yajo opened this issue Sep 25, 2021 Discussed in #449 · 0 comments · Fixed by #453
Closed

Support updating a subproject when it isn't in the root of the git repo #451

yajo opened this issue Sep 25, 2021 Discussed in #449 · 0 comments · Fixed by #453

Comments

@yajo
Copy link
Member

yajo commented Sep 25, 2021

Discussed in #449

Originally posted by flippedAben September 22, 2021
I have a Git repo at ~/repo. I have another Git repo at ~/my_copier_template. I tell copier to use ~/my_copier_template to generate a subproject at ~/repo/path/to/S (call it S for short). I track my new subproject in ~/repo by adding and committing the changes.

When I try to update S, it fails at:

copier/copier/main.py

Lines 607 to 610 in b8ff4d8

if self.subproject.vcs != "git":
raise UserMessageError(
"Updating is only supported in git-tracked subprojects."
)

This is because copier assumes that a subproject is tracked by Git if and only if it is in the root of a git repo, as stated here:

def vcs(self) -> Optional[VCSTypes]:
"""VCS type of the subproject."""
if is_git_repo_root(self.local_abspath):
return "git"

But, S is not at the root of ~/repo. I would like to change copier to support this scenario, but wanted to get some thoughts before proceeding.

Part of the change will involve changing how we update:

copier/copier/main.py

Lines 670 to 673 in b8ff4d8

git("fetch", "--depth=1", "real_dst", "HEAD")
diff_cmd = git["diff-tree", "--unified=1", "HEAD...FETCH_HEAD"]
try:
diff = diff_cmd("--inter-hunk-context=-1")

How do we feel about not doing the fetch, and doing a git diff between R:/path/to/S and the cleanly generated T, instead of git diff-tree.

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