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

add gist clone command #2222

Merged
merged 1 commit into from Dec 18, 2020
Merged

add gist clone command #2222

merged 1 commit into from Dec 18, 2020

Conversation

Crunch09
Copy link
Contributor

This adds the ability to clone a gist, very similar to the repo clone command.

Usage:

$ gh gist clone 5b0e0062eb8e9654adad7bb1d81cc75f
$ gh gist clone https://gist.github.com/OWNER/5b0e0062eb8e9654adad7bb1d81cc75f

This closes #2115.

gist_clone

gistURL = ghinstance.GistPrefix(hostname) + gistURL
}

_, err := git.RunClone(gistURL, opts.GitArgs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The repo clone command sets the upstream repository of a fork automatically on clone so I tried to do this for the gist clone command as well.
However, it looks like while the gist GraphQL Object can tell if its a fork or not, it doesn't have any link to the parent gist.


if !git.IsURL(gistURL) {
hostname := ghinstance.OverridableDefault()
gistURL = ghinstance.GistPrefix(hostname) + gistURL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add the protocol here because it would have required changes on the ghrepo.FromFullName function and cloning worked without it but happy to do that if required!

@samcoe samcoe added this to Backlog 🗒 in The GitHub CLI via automation Oct 19, 2020
@samcoe samcoe moved this from Backlog 🗒 to Needs review 🤔 in The GitHub CLI Oct 19, 2020
@vilmibm vilmibm self-requested a review November 16, 2020 22:16
Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

thank you for this! I tested it out locally and it worked well~

I'd love for this command to respect the git_protocol setting. I have mine set for ssh but the origin remote on my clone used https; could you try adding support for that? I'm happy to help if it's unclear how to do so or if any of the supporting functions need refactoring.

@Crunch09
Copy link
Contributor Author

Crunch09 commented Dec 3, 2020

Thanks for the review @vilmibm -- makes total sense! I'll try to make the requested changes on the weekend and report back then!

This adds the ability to clone a gist.

Usage:

```sh
$ gh gist clone 5b0e0062eb8e9654adad7bb1d81cc75f
$ gh gist clone https://gist.github.com/OWNER/5b0e0062eb8e9654adad7bb1d81cc75f
```

This closes cli#2115.
@Crunch09
Copy link
Contributor Author

Crunch09 commented Dec 7, 2020

Updated to take git_protocol into account and it seems to be working as expected now @vilmibm please let me know if you still encounter any issues :)

@vilmibm vilmibm self-requested a review December 16, 2020 19:37
Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

thank you!!!!

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Dec 18, 2020
@vilmibm vilmibm merged commit 230441e into cli:trunk Dec 18, 2020
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Dec 18, 2020
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Jan 21, 2021
Copy link

@shivaybaxi shivaybaxi left a comment

Choose a reason for hiding this comment

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

222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

Support cloning a gist (just like cloning a repo)
3 participants