Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

push_files inconsistencies #133

Open
svenevs opened this issue Nov 10, 2016 · 0 comments
Open

push_files inconsistencies #133

svenevs opened this issue Nov 10, 2016 · 0 comments

Comments

@svenevs
Copy link
Contributor

svenevs commented Nov 10, 2016

Hello, I've seen a couple of issues on here and believe that people are having trouble with push_files because of the treatment of URL's. I'm in a situation where I need to modify a script to enable anybody on staff to execute this thing, and instead of assuming they have their SSH keys setup properly with the github enterprise account, I enforce that they have $TEACHERS_PET_GITHUB_TOKEN set.

This works well for cloning and creating repos etc, but the issue with push_files is that it defaults to using ssh for some reason, unlike the other commands. That is, even if I tell it --token.

Example:

Functioning as-expected for create repos

tp_auth="--web=$gh_web --api=$ghb_api --organization=$ghb_org --username=$grader_netid --token"
tp_spec="--students=$student_file --repository=$repo_name"
# Create the repositories as private                        
teachers_pet create_repos $tp_auth $tp_spec --no-public

these variables simply specify the url's, the username (which will almost certainly be different than their git config), and --token (already previously verified the token is set).

However,

teachers_pet push_files $tp_auth $tp_spec

will fail, and inspection reveals this is what happened:

origin  https://<MY_TOKEN>@<ENTERPRISE>/<GROUP>/a7-starter.git (fetch)
origin  https://<MY_TOKEN>@<ENTERPRISE>/<GROUP>/a7-starter.git (push)
team-XXX       [email protected]:<GROUP>/team-XXX-final.git (fetch)
team-XXX       [email protected]:<GROUP>/team-XXX-final.git (push)
team-YYY       [email protected]:<GROUP>/team-YYY-final.git (fetch)
team-YYY       [email protected]:<GROUP>/team-YYY-final.git (push)

Basically, even though I asked for --token it will use my ssh key which is not associated (intentionally) with my enterprise github account. In my script I am specifically cloning this repo as

starter_repo="a7-starter"
oauth_url="https://$TEACHERS_PET_GITHUB_TOKEN@<ENTERPRISE>/$ghb_org/$starter_repo.git"
git clone $oauth_url

because the repo does not follow the standard "team-repo_name" teachers_pet is expecting (which is nbd), but I just wanted to explain how that origin got that way in the first place.

So I think the reason people are having trouble with push_files may be because it is grabbing ssh keys without asking, and my understanding of the code is the --token doesn't apply.

I don't know how to fix it (ruby is beautiful, but quite foreign), but figured I'd post this in case it is an easy fix. Let me know if you need more data.

Edit: to clarify, I solved it by just using --ssh=<enterprise url> and adding my ssh key to the enterprise account, but I feel like the push_files command should be able to use just the --token. But perhaps not?

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

No branches or pull requests

1 participant