Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make github repos sticky
import git
import json
import time
import urllib2
import datetime
def is_first(org, repo):
url = "" % org
get = urllib2.urlopen(url).read()
data = []
for repo in json.loads(get):
timestamp = time.strftime("%s", time.strptime(repo['pushed_at'], "%Y-%m-%dT%H:%M:%SZ"))
data.append({"name": repo['name'].lower(), "modified" : int(timestamp)})
newlist = sorted(data, key=lambda x: x['modified'])
return newlist[-1]['name'] == repo
if __name__ == '__main__':
if not is_first('coderdojosf', 'welcome'):
dname = '/home/ktalwar/git/welcome'
fname = dname + '/sticky.txt'
open(fname, 'a').write(' ')
repo = git.Repo(dname)
repo.git.commit(m='sticky post')
master = repo.remotes.origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment