Gists Vrs Repos for sharing Pythonista code
I was reading about Gists, and the docs say that they are functionally equivalent to repos, in regards to cloning, forking etc...
@ccc, I noticed you had a post before about Gists being unmanaged. Have they changed since you wrote that? Or are Gists inferior to repos. From what I read, a gist is a repo.
I understand this is not Pythonista specific, but just trying to work out the best way to go. As Pythonista has some support for Gists, it would make sense to use them if they are functionally equivalent.
I'm not actually sure how to store a password inside the web app such that it can't be accessed publicly. I've asked on security.stackexchange.com to see if anyone knows.
Here is a howto clone your own repo, change a file and push it back with stash.
[~/Documents]$ mkdir Github
[~/Documents]$ cd Github
[Github]$ mkdir ui-tutorial
[Github]$ cd ui-tutorial
[ui-tutorial]$ git clone https://github.com/humberry/ui-tutorial.git
.git (374.0B) 2016-02-16 21:27:36
MiniPhotoView.py (3.4K) 2016-02-16 21:28:55
[ui-tutorial]$ edit MiniPhotoView.py
[ui-tutorial]$ git status
UNSTAGED LOCAL MODS
[ui-tutorial]$ git commit
Commit Message: remove touch and layout method
Author Name: myusername
Save this setting? [y/n]y
Save this setting? [y/n]y
[ui-tutorial]$ git push
Attempting to push to: https://github.com/humberry/ui-tutorial.git, branch: refs/heads/master
Enter username: myusername
Enter password: mysecretpassword
Push to https://myusername:firstname.lastname@example.org/humberry/ui-tutorial.git successful.
@ccc The commands I listed are for working with a repo that you own or have write access for. I'm not sure if GitHub forking is possible from the command line, there seems to be a lot of GitHub-specific stuff involved with the process. (Honestly I don't know how one would fork a repo independent of GitHub, or if that really just involves making a copy of the repo.)
Guys.... Dealing with a repo that you own is child's play.
GitHub's examples explain the entire workflow of dealing with your own repo in an easy to understand way. You have full read/write permissions so you can just Push changes directly into the repo without even needing to resort to Pull Requests.
The complexities for me come when I want to send a Pull Request into a repo that I do not own and I am not a "contributor" to. That is why the bold text in my post above is: create Pull Requests into GitHub repositories that I do not own.
I would still really like to see someone replicate my approach above using Working Copy app in place of GitHub Desktop.
@ccc GitHub specific functions can be accessed through GitHub API v3, including fork, create pull request etc. It should be possible to write a command line tool for them. But it is so convenient already to just do them via the webpages. It seems to me that the API is really for people who develope apps for GitHub, eg working copy. If you don't pay for the API, it is limited to about 60 calls per hour.
@ccc I do the initial "fork" of the repo using the website. Then I can create branches off my fork's
masterbranch and commit to them using the command line. That should also be possible in stash. Once I'm done I send the PR through the website again.
If my fork's
masterbranch gets outdated, I do
git merge upstream/master(replace
upstreamwith the original repo owner name, or add it as a remote by hand) which should always result in a fast-forward because I never do any changes to my
@ywangd Github has the
hubcommand-line tool for these things https://hub.github.com. It provides all git functions, as well as some that are specific to GitHub. They recommend aliasing
hubto make it the default command-line interface for Git.
@Webmaster4o Thanks I wasn't aware of this tool. But it does not help in our situation as it cannot run inside Pythonista or even iOS. It is written in Go.
@ywangd Right. I was just pointing it out ;)
Guys, I hope I didn't come off as complaining. I have a very high regard for all you guys and how much you are will to share and do. I was just emotional and frustrated. But the good news is you only get emotional about things you care about. It looks @ccc post got the topic started again though was is great. I think one thing that frustrates me, is that I can only talk about it. I can't really do anything that I am aware to contribute.
Oh, well. As I say just hope I didn't offend anyone. Was the furthest thing from my mind.
For what it is worth, PyGithub seems to work well. I may wrap a simple stash commandline around this. pygithub doesn't seem to support creation of files, but that is what stash git is for. There may be other forks with more complete support (enix223/master).
Anyway, the short and sweet:
Create new repo:
from github import Github g = Github(user,pass) #or, g=Github(token) where token is personal Oauth token u= g.get_user() u.create_repo('new_repo')
or, to Fork a repo
other_repo = g.get_repo('cclauss/GitHub-web-plus-app-workflow') mine=u.fork_repo(other_repo)
Create a pull request (after using stash to push to your own github)
# call create_pull on the repo you want to pull INTO. base = name of branch in that repo. head = name of YOUR repo, as user:branch other_repo.create_pull(title='A web-free example, using only python', body='here is a simple example using pygithub to fork a repo, then create a pull request', base='master', head='jsbain:master')