Skip to content

Use urlEncode to handle spaces in file names, closes #432 - #434

Closed
ericwooley wants to merge 3 commits into
lerna:masterfrom
ericwooley:issue-432
Closed

ericwooley wants to merge 3 commits into
lerna:masterfrom
ericwooley:issue-432

Conversation

@ericwooley

Copy link
Copy Markdown

No description provided.

@ericwooley

Copy link
Copy Markdown
Author

I added files in the test fixture that has spaces in them. Which broke the tests, then fixed them. Hopefully that is enough test coverage.

Comment thread src/commands/ImportCommand.js Outdated
// Map files to original and urlEncoded
.map(function (file) {
return {
encodedString: encodeURIComponent(file),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whoa, git am supports URL encoded filenames? Nice find!

Comment thread src/commands/ImportCommand.js Outdated
// Remove all url encoded file names from patch
patch = filesInPatch.reduce(function (partiallyReplacedPatch, file) {
return partiallyReplacedPatch.replace(new RegExp(file.encodedString, "mg"), file.originalString);
}, patch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh! I see, you're un-doing the URL encoding.

I like this solution. Much nicer than trying to make a regex that handles the spaces!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! Yea, I could not find a reasonable way at all to do regex.

However this is still running into other problems I have yet to figure out on the larger repos.

I am using git subtree to import them, and it seems to have worked really well. I'm still trying to figure out if it worked correctly in terms of commit history.


// Replace all file names with url encoded file names
patch = filesInPatch.reduce(function (partiallyReplacedPatch, file) {
return partiallyReplacedPatch.replace(new RegExp(file.originalString, "mg"), file.encodedString);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any danger here of regex meta characters in a filename messing up the match?

Or will the URL encoding take care of that?

@ericwooley

Copy link
Copy Markdown
Author

It seems like maybe this should be closed? It's been open for quite a while, and has since been conflicted.

@evocateur evocateur closed this Oct 28, 2017
@lock

lock Bot commented Dec 27, 2018

Copy link
Copy Markdown

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants