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

Normalizes path for git and git submodules #73

Merged
merged 1 commit into from
Aug 29, 2016

Conversation

lorengordon
Copy link
Contributor

@lorengordon lorengordon commented Aug 26, 2016

_git_ls_files() returns file paths with forward slashes. For files
in submodules, add_prefix_to_each() is called to prefix all the
submodule files with the relative path to the project root. On Windows,
the relative path contains backslashes. Since not every file in the
project is in a submodule, the combined list of files ended up with
some files that use forward slashes and others that use backslashes.

For project structures where the submodules share a path segment with
the project source, this caused add_directories() to create duplicate
directory entries in the list of files. The duplicate entries would
result in a traceback with a WindowsError when os.mkdir() was called
to create the same directory a second time.

See #61 for more details.

This commit ensures the list of files contains only forward slashes
before calling add_directories(), eliminating the duplicate directory
entries.

@lorengordon lorengordon force-pushed the fix-submodules branch 3 times, most recently from 78cec61 to 74eeda7 Compare August 26, 2016 22:40
`_git_ls_files()` returns file paths with forward slashes. For files
in submodules, add_prefix_to_each() is called to prefix all the
submodule files with the relative path to the project root. On Windows,
the relative path contains backslashes. Since not every file in the
project is in a submodule, the combined list of files ended up with
some files that use forward slashes and others that use backslashes.

For project structures where the submodules share a path segment with
the project source, this caused `add_directories()` to create duplicate
directory entries in the list of files. The duplicate entries would
result in a traceback with a WindowsError when `os.mkdir()` was called
to create the same directory a second time.

See mgedmin#61 for more details.

This commit ensures the list of files contains only forward slashes
before calling `add_directories()`, eliminating the duplicate directory
entries.
@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

Normalizing slashes and backslashes internally seems like a great idea.

I also want to have a regression test for this issue. I can write one, but I'd appreciate some help distilling #61 (comment) into a sequence of commands I could run on Windows to reproduce this.

@lorengordon
Copy link
Contributor Author

lorengordon commented Aug 29, 2016

Will pseudo-commands work well enough? I can take another look at the tests later this afternoon, also.

git init
mkdir project
mkdir project/submodules
touch project/__init__.py
git submodule add https://some/otherproject.git project/submodules/otherproject

@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

https://github.com/mgedmin/check-manifest/blob/master/tests.py#L942-L966 is the current test for submodules, and I see that all the submodules I've added are at the top level of each respective repository.

Let me see what Appveyor will say if I move one of those into a subdir.

mgedmin added a commit that referenced this pull request Aug 29, 2016
This might suffice as a regression test for #73.
@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

Appveyor sees duplicate entries in the list! Let me now try your patch on top of this new test.

mgedmin added a commit that referenced this pull request Aug 29, 2016
@lorengordon
Copy link
Contributor Author

That's some neat git- and ci-foo there. Will need to remember that trick.

@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

Ok, Appveyor shows success (although GitHub stopped showing me CI status because computers
¯_(ツ)_/¯ ), let's merge this!

@mgedmin mgedmin merged commit c545bfb into mgedmin:master Aug 29, 2016
mgedmin added a commit that referenced this pull request Aug 29, 2016
This might suffice as a regression test for #73.
@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

I'll cut a release after I see that my Jenkins is also happy (sometimes it breaks when Appveyor is fine, and sometimes Appveyor breaks when my Jenkins is fine, and everything is terrible). Jenkins builds take 25 minutes on Windows for some reason (because git is slooooow on Windows? but not on Appveyor? because the git I have in my VM is older? I don't know!).

@lorengordon
Copy link
Contributor Author

Right on. Git for Windows has been a pretty amazing project lately... probably worth trying a newer version if you're running something older.

https://github.com/git-for-windows/git/releases

@lorengordon
Copy link
Contributor Author

Maybe add a git --version statement to appveyor.yml?

@lorengordon lorengordon deleted the fix-submodules branch August 29, 2016 12:57
@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

The git I've got on my Jenkins is version 1.8.4.msysgit.0.

I can download a newer release and try to install, and then it complains that C:\Git already exists and doesn't seem to know anything about the concept of upgrading existing software and 🔥 🔥 🔥 this is why I never upgrade stuff on Windows where is my apt-get?

@lorengordon
Copy link
Contributor Author

Oh man, yeah, that version is ancient! 😛

Git-for-Windows made a pretty big switch away from msysgit last year (I think). Should (probably) not run into similar upgrade issues using the newer versions... (One hopes...)

@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

Ooh, in Add/Remove programs the version is even more fun: 1.8.4-preview20130916.

I'll wait for the build to complete, uninstall then install a new version (and hope this won't wipe my ~/.bashrc and other customizations).

@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

Whoops, this digression belongs in the comments of #63.

@mgedmin
Copy link
Owner

mgedmin commented Aug 29, 2016

check-manifest 0.33 is out on PyPI!

@lorengordon
Copy link
Contributor Author

🎆 🏆

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.

2 participants