- Notifications
You must be signed in to change notification settings - Fork5
Add url parameter in set_github_pat()#9
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
jennybc left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Currently we require the full API in the url, so the user needs to specify like:
set_github_pat(url = "https://github.ucla.edu/api/v3/")`. Alternatively we could let the user just specify the hostname part from the github enterprise docs because everything else is fixed.
I would really like to allow this:
- input URL is "https://github.com" or "https://api.github.com" --> leads to lookup for "https://github.com", validation against "https://api.github.com/user"
- input URL is "https://github.acme.com/api/v3" or "https://github.acme.com" --> leads to lookup for "https://github.acme.com", validation against "https://github.acme.com/api/v3/user"
So I'd likeurl to be accepted in "browser" or "API" form. But I also don't want to have to pre-strip the protocol. Similar changes are in the dev version of gh now.
| return(do.call(Sys.setenv, structure(list(cred$password),names=pat_var))) | ||
| } | ||
| } | ||
| if(verbose==TRUE){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nitpick
| if(verbose==TRUE){ | |
| if(isTRUE(verbose)){ |
| pat_url<- sprintf('https://%s@github.com',pat_user) | ||
| set_github_pat<-function(force_new=FALSE,url='https://api.github.com', | ||
| validate= interactive(),verbose=validate){ | ||
| url_data<- get_pat_credential_url(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would a name involving "parse" or similar be more self-explanatory?
| # safely parse _AT_ to look for custom usernames. | ||
| get_pat_credential_url<-function(url){ | ||
| # strip protocol | ||
| url<- sub("^[a-z]+://","", tolower(url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thistolower() is in tension with what gh has been doing when forming these env var names.
| pat_var<-if(grepl("github.com$",url)){ | ||
| 'GITHUB_PAT' | ||
| }else { | ||
| paste0('GITHUB_PAT_', gsub("\\.","_", sub("^.+@","",url))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
gh doestoupper(url) (modulo the fact that it does not have any notion of such a URL containing a username).
jennybc commentedAug 13, 2020
As for supporting and slugifying username ... we could NOT support that initially, in order to make it easier to move forward now. Getting support for non-github.com deployments feels like 90% of the win here and we can wait and see if people actually ask for username support. |
jennybc commentedAug 14, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For the Windows Git Credential Manager, the GCM_INTERACTIVE environment variable is very intriguing to me: http://microsoft.github.io/Git-Credential-Manager-for-Windows/Docs/Environment.html#gcm_interactive
|
b01c10f to32fd1eaCompare0277735 to883e07aCompare
Uh oh!
There was an error while loading.Please reload this page.
Many open questions:
GCM_AUTHORITY=Basic.set_github_pat(url = "https://dummy@github.com")and have that as my newGITHUB_PAT.set_github_pat(url = "https://github.ucla.edu/api/v3/"). Alternatively we could let the user just specify thehostnamepart from thegithub enterprise docs because everything else is fixed.