Created
October 27, 2013 20:06
-
-
Save seveas/7187313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
branch = repo.ref('heads/gh-pages') | |
parent = repo.commit(branch.object.sha) | |
files = os.listdir('.') | |
blobs = [] | |
for (dir, _, files) in os.walk('.'): | |
dir = dir[2:] | |
for file in files: | |
with open(os.path.join(dir, file)) as fd: | |
sha = repo.create_blob(fd.read().encode('base64'), "base64") | |
blobs.append({'path': os.path.join(dir, file), 'mode': '100644', 'type': 'blob', 'sha': sha or empty_file_hash}) | |
tree = repo.create_tree(blobs) | |
if tree.sha != parent.commit.tree.sha: | |
self.logger.info("Creating new commit") | |
commit = repo.create_commit("Automatic update from commit %s" % job.commit, | |
tree=tree.sha, parents=[parent.sha], | |
author={'name': 'Golem', 'email': 'golem@seveas.net'}) | |
branch.update(commit.sha) | |
else: | |
self.logger.info("No change, not creating commit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment