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

Quarks Windows fixes #1956

Merged
merged 1 commit into from
Apr 7, 2016
Merged

Quarks Windows fixes #1956

merged 1 commit into from
Apr 7, 2016

Conversation

bagong
Copy link
Contributor

@bagong bagong commented Apr 7, 2016

  • detect git
  • modify git command to list refspecs
  • exclude URLs from path detection

(includes code form crucialfelix' pr #1954 )

^string.findRegexp(regex.isPath).size != 0
}, {
^(string.findRegexp(regex.isPath).size != 0).and(string.findRegexp(regex.isURL).size == 0)
});
Copy link
Member

Choose a reason for hiding this comment

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

but how can a URL ever match "\\\\|/" ? are you sure that's what happened with that example you sent me ?

Copy link
Member

Choose a reason for hiding this comment

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

oh I see, it is a bad regexp:

r = "\\\\|/"
u = "https://github.com/crucialfelix/crucial-library"
u.findRegexp(r)
 [ [ 6, / ], [ 7, / ], [ 18, / ], [ 31, / ] ]

I don't know why there is |/ in there

p = "C:\\Users\\Rainer\\Projects\\sc\\supercollider\\build_MW_IPCfix_Rl\\editors\\sc-ide\\Release";
u = "https://github.com/crucialfelix/crucial-library";

r = "\\\\|/";

p.findRegexp(q); // truthy
u.findRegexp(q); // truthy

q = "\\\\"; // simpler: just detect one slash

p.findRegexp(q); // truthy
u.findRegexp(q); // falsey

and then no need for two regexp checks or an if statement there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

r = "\\\\|/"

First it's not from me, but I think it's correct, though it's likely over-general.
You get 4 "\" because it looks for an already escaped "\". So it looks for "\\" and escapes each of them in the match string
"/" has to be there because that's also allowed in Windows. It would be nice to leave it away, as it would make distinguishing URLs a lot easier, but you wouldn't want to tell people "don't use forward slashes" if it's actually nicer to do so (no escaping needed, cross-platform...). I guess quite a bit of code depends on that "/" can be used as folder delimiter in Windows too.

@@ -80,7 +80,11 @@ Git {
// all tags
// only includes ones that have been fetched from remote
^tags ?? {
raw = this.git(["for-each-ref --format='%(refname)' --sort=taggerdate refs/tags"]);
if(thisProcess.platform.name !== 'windows', {
raw = this.git(["for-each-ref --format='%(refname)' --sort=taggerdate refs/tags"]);
Copy link
Member

Choose a reason for hiding this comment

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

just a note to clarify for others: sh family of shells require quote marks

crucial-library ❯ git for-each-ref --format=%(refname) --sort=taggerdate refs/tags
zsh: missing end of string

@bagong is saying that windows doesn't want the quote, otherwise he gets:

C:\Users\Rainer\AppData\Local\SuperCollider\downloaded-quarks\crucial-library>git for-each-ref --format='%(refname)' --sort=taggerdate refs/tags
…
'refs/tags/for-SC-3.4.1'
'refs/tags/for-sc-3.5rc1'
'refs/tags/4.0.0'
'refs/tags/4.0.1'
'refs/tags/4.1'
'refs/tags/4.1.1'
'refs/tags/docs-syntax-fixes'
'refs/tags/ilisp-help'
'refs/tags/4.1.3'
'refs/tags/4.1.4'
'refs/tags/4.1.5'

@crucialfelix
Copy link
Member

It's from james harkins. your explanation rings true — thanks. so you are right, we do need to reject URLs.

regexp.isUrl could be just "http" and it's fine to call check that on all platforms and thus avoid the extra if statement.

but I guess it does work now so maybe we should just move on. its up to you - make minor change to remove the extra if branch or should we just merge it as is ?

@bagong
Copy link
Contributor Author

bagong commented Apr 7, 2016

Well, I think I've still seen a statement using "git" as protocol, so I thought something more general would be better. I think it's safe to generalize it to "://", maybe similar safe as the "\\\\|/" one.
Also, while it's unlikely, "http" could be a substring in a path, right?
I'd suggest to move on and merge, if it doesn't matter that I used "!==" once and "!=" another time, just saw it this morning. Too untidy?
And maybe merge yours first? It's included in mine as I wanted to make sure I wasn't working on a shaky ground ;)

@bagong
Copy link
Contributor Author

bagong commented Apr 7, 2016

Oh, it's actually correct, ya, one is a symbol and the other is an integer... So ignore that ;) Haha, sometimes copy-pasting others code prevents realizing details ;)

@bagong
Copy link
Contributor Author

bagong commented Apr 7, 2016

Maybe @jamshark70 wants to lend an eye and commit if he thinks it's okay.

@crucialfelix crucialfelix merged commit d9494b7 into supercollider:3.7 Apr 7, 2016
@jamshark70
Copy link
Contributor

It looks good to me. You're right, I was trying to match paths with either a backslash or forward slash. But, if I had a nickel for every time I messed up the escapes in a regex, I could pay Donald Trump to drop out of the election.

I'm ok with any code that works -- you're more than welcome to fix my mistakes ;)

@bagong bagong deleted the prQuarks branch April 7, 2016 09:32
@crucialfelix
Copy link
Member

Your original fix was right, it's still right. We might comment it with an explanation so it's not so "wtf?" for future generations.

@bagong
Copy link
Contributor Author

bagong commented Apr 7, 2016

Yep, the problem is not that "/" is in there but that the program logic requires URLs to be excluded. Thanks for looking and sharing responsibility by committing!

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

Successfully merging this pull request may close these issues.

3 participants