Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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!

@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!!!!

@vilmibm vilmibm merged commit 230441e into cli:trunk Dec 18, 2020
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

None yet

Development

Successfully merging this pull request may close these issues.

Support cloning a gist (just like cloning a repo)

3 participants