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

Accept common URLs as repo spec in parse_github_repo_spec(); closes #90 #108

Closed
wants to merge 4 commits into from

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Sep 13, 2017

PLEASE DO NOT MERGE THIS. As discussed, I'd like to make this PR live from my R-Ladies thing tomorrow night. But let's discuss if this solution is OK. Once true, I will close this and make the real PR then. I just did it in the simplest way, w/o disturbing the world's scariest regex just below 😃


parse_github_repo_spec <- function(repo) {

repo <- gsub("\\.git$", "", repo)
Copy link
Member

Choose a reason for hiding this comment

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

I would only remove the .git suffix with the prefixes, because some git urls might not handle the .git-less form, like GitHub.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK I can do that. But just to check ... what are you actually worried about? That there might be a .git I should not strip? That there might be a GitHub repo actually named foo.git and jenny/foo.git should return username = jenny and repo = foo.git?

@gaborcsardi
Copy link
Member

Thanks! Otherwise it looks great, I have wanted this for a long time!

@gaborcsardi
Copy link
Member

You can submit the exact same PR if you want, and I'll be online to request the change. :)

@gaborcsardi
Copy link
Member

and a bullet point in NEWS...

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

See what you think now.

I don't immediately see why travis r-devel is failing now but passed initially for this PR. Update: I restarted that job and then it passed.

@@ -1,6 +1,9 @@

# 1.1.0

* Accept browser, HTTPS, or SSH URL in GitHub repo specification,
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by "browser"?

Copy link
Member Author

Choose a reason for hiding this comment

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

The URL that appears in your browser when you visit a repo. I frequently capture those on the clipboard. Maybe it's just a habit of mine?

If I've managed to make that clear ... can you think of a better term?

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 is that different from just a HTTPS url?

Copy link
Member

Choose a reason for hiding this comment

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

Or any URL within the repo is supposed to work? Like this one works as well: https://github.com/r-lib/remotes/pull/108?

@gaborcsardi
Copy link
Member

Actually, you are right, chopping off the .git is fine. I was just confused and thought that chopping off the .git might break other remote types (because it is used for bitbucket for example, quite confusingly), but you are right, it would not break anything.

So feel free to submit the original or the updated form.

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

So feel free to submit the original or the updated form.

I think it does feel more contained the way it is now, so better.

I will close this and make a fresh one sometime between 7:30 and 8:10pm tonight. But I'm still going to point to this, because it's ended up being a good example of a PR process!

@jennybc jennybc closed this Sep 14, 2017
@gaborcsardi
Copy link
Member

Sorry, one more question. URLs like https://github.com/r-lib/remotes/pull/108 don't work, right? Or they do?

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

No that would currently give the wrong result. The only "browser URL" that explicitly works is the main one https://github.com/USERNAME/REPO. Anything else would be a happy coincidence.

library(remotes)
parse_github_repo_spec("https://github.com/r-lib/remotes/pull/108")
#> $username
#> [1] "r-lib"
#> 
#> $repo
#> [1] "remotes"
#> 
#> $subdir
#> [1] "pull/108"

I thought about this. There are many forms (pull requests, releases, etc.) but didn't want to tackle all of them. I still think the current addition is worth it but, yeah, don't want to overpromise re: browser URL support.

@gaborcsardi
Copy link
Member

How about just cutting off that part?

@gaborcsardi
Copy link
Member

At least for now?

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

Maybe I should just mention the HTTPS and SSH URLs in the help and let the other be an undocumented things that works.

We are typing at same time, but is that basically what you mean?

@gaborcsardi
Copy link
Member

I mean, I would just cut off the rest of the URL, i.e. https://github.com/r-lib/remotes/pull/108#issuecomment-329440222 would be interpreted as https://github.com/r-lib/remotes

Although this is not a good idea if we want to implement sg special for the various urls.

OK, I think it would be better to give an error in this case. So basically, the URL has to end with the repo name.

You don't need to do this for today, but I think in the long term it would make sense.
We'll add it to the new giant regex later :)
https://github.com/r-lib/depends/blob/20b52bb2c9d1680f02cb2d10dc75af1f9a946dc4/R/parse-remotes.R#L6

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

Got it.

@jennybc jennybc reopened this Sep 14, 2017
@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

OK, I think it would be better to give an error in this case. So basically, the URL has to end with the repo name.

I've added this, i.e. the only browser-style URLs that work are the HTTPS remote URL and the top-level URL. Otherwise, they error.

I also made it work for GitHub enterprise URLs, since I see that install_github() supports that.

How does this look?

@gaborcsardi
Copy link
Member

Great! Thanks much!

@jennybc
Copy link
Member Author

jennybc commented Sep 14, 2017

Taken care of, as planned, in #109.

@jennybc jennybc closed this Sep 14, 2017
@jennybc jennybc deleted the install-github-from-full-url branch September 18, 2017 15:35
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