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

ci-status without local repo #2344

Closed
AndreasBergmeier6176 opened this issue Nov 6, 2019 · 5 comments
Closed

ci-status without local repo #2344

AndreasBergmeier6176 opened this issue Nov 6, 2019 · 5 comments

Comments

@AndreasBergmeier6176
Copy link

Currently I am trying to retrieve ci-status from a repo.

Looking at the code, it seems like it enforces a local repo clone!? Could someone please explain why that is?
AFAIK the ci-status is not directly linked to the git graph and thus should work fine without a local clone (which takes time).

The problem is made worse by the fact that cloning is non-trivial in a containerized environment (Kubernetes).
I was hoping that hub clone would do the trick in combination with GITHUB_TOKEN but it seems like I missed the point of hub clone.

@AndreasBergmeier6176 AndreasBergmeier6176 changed the title ci-status without repo ci-status without local repo Nov 6, 2019
@mislav
Copy link
Owner

mislav commented Nov 6, 2019

You are correct in your observations—hub was primarily designed to be run from the context of a git repo.

This requirement makes less sense for commands such as ci-status, I agree. We are considering adding a --repo=OWNER/REPO flag to all commands so that you may run them without having to clone or cd into anything. Please follow for updates #2338

In the meantime, you can work around this by initializing an empty repository, no need to clone anything:

git init 
git remote add origin "https://github.com/OWNER/REPO"
hub ci-status ...

It might look a bit clumsy but it's cheap (resource-wise) and will work well.

@mislav mislav closed this as completed Nov 6, 2019
@AndreasBergmeier6176
Copy link
Author

AndreasBergmeier6176 commented Nov 6, 2019

It might look a bit clumsy but it's cheap (resource-wise) and will work well.

It is a private repo. So I would have to setup a whole ssh setup inside the Container. Which seems like pure overkill.

For now I work around this with:

hub api repos/$GITHUB_REPOSITORY/commits/master/status | jq -r .state

@mislav
Copy link
Owner

mislav commented Nov 6, 2019

It is a private repo. So I would have to setup a whole ssh setup inside the Container. Which seems like pure overkill.

Hub does all its API operations over HTTPS, not SSH. As my workaround above doesn't involve any cloning or git transfer whatsoever (look at it closely; adding the git remote is only so that hub can pick up the correct GitHub repository), you don't need to set up SSH. You only need to provide hub with a GITHUB_TOKEN that has access to your private repo.

@AndreasBergmeier6176
Copy link
Author

Hub does all its API operations over HTTPS, not SSH. As my workaround above doesn't involve any cloning whatsoever (adding the git remote is only so that hub can pick up the repository URL), you don't need to set up SSH. You only need to provide hub with a GITHUB_TOKEN that has access to your private repo.

If you look at my example, I want to get the status of master. In your empty local clone, it cannot lookup master and thus complains: Aborted: no revision could be determined from 'master'

@mislav
Copy link
Owner

mislav commented Nov 6, 2019

Ah sorry, you're right. hub ci-status does try to de-reference arguments passed using the local git repo.

Your hub api workaround is better. 🙇

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

No branches or pull requests

2 participants