ghp-import-0.5.5/0000755000076500000240000000000013054434062014221 5ustar davispstaff00000000000000ghp-import-0.5.5/ghp_import.egg-info/0000755000076500000240000000000013054434062020063 5ustar davispstaff00000000000000ghp-import-0.5.5/ghp_import.egg-info/dependency_links.txt0000644000076500000240000000000113054434062024131 0ustar davispstaff00000000000000 ghp-import-0.5.5/ghp_import.egg-info/entry_points.txt0000644000076500000240000000006013054434062023355 0ustar davispstaff00000000000000[console_scripts] ghp-import = ghp_import:main ghp-import-0.5.5/ghp_import.egg-info/not-zip-safe0000644000076500000240000000000113054434062022311 0ustar davispstaff00000000000000 ghp-import-0.5.5/ghp_import.egg-info/PKG-INFO0000644000076500000240000001130213054434062021155 0ustar davispstaff00000000000000Metadata-Version: 1.1 Name: ghp-import Version: 0.5.5 Summary: Copy your docs directly to the gh-pages branch. Home-page: http://github.com/davisp/ghp-import Author: Paul Joseph Davis Author-email: paul.joseph.davis@gmail.com License: Tumbolia Public License Description: GitHub Pages Import =================== As part of [gunicorn][gunicorn], [Benoit Chesneau][benoit] and I have been starting to look at how to host documentation. There's the obvious method of using [GitHub's post-receive hook][github-post] to trigger doc builds and rsync to a webserver, but we ended up wanting to try out github's hosting to make the whole interface a bit more robust. [GitHub Pages][gh-pages] is a pretty awesome service that GitHub provides for hosting project documentation. The only thing is that it requires a `gh-pages` branch that is the site's document root. This means that keeping documentation sources in the branch with code is a bit difficult. And it really turns into a head scratcher for things like [Sphinx][sphinx] that want to access documentation sources and code sources at the same time. Then I stumbled across an interesting looking package called [github-tools][github-tools] that looked almost like what I wanted. It was a tad complicated and more involved than I wanted but it gave me an idear. Why not just write a script that can copy a directory to the `gh-pages` branch of the repository. This saves me from even having to think about the branch and everything becomes magical. This is what `ghp-import` was written for. [gunicorn]: http://www.gunicorn.com/ "Gunicorn" [benoit]: http://github.com/benoitc "Benoît Chesneau" [github-post]: https://help.github.com/articles/post-receive-hooks "GitHub Post-Receive Hook" [gh-pages]: http://pages.github.com/ "GitHub Pages" [sphinx]: http://sphinx.pocoo.org/ "Sphinx Documentation" [github-tools]: http://dinoboff.github.com/github-tools/ "github-tools" Big Fat Warning --------------- This will **DESTROY** your `gh-pages` branch. If you love it, you'll want to take backups before playing with this. This script assumes that `gh-pages` is 100% derivative. You should never edit files in your `gh-pages` branch by hand if you're using this script because you will lose your work. Usage ----- Usage: ghp-import [OPTIONS] DIRECTORY Options: -n Include a .nojekyll file in the branch. -c CNAME Write a CNAME file with the given CNAME. -m MESG The commit message to use on the target branch. -p Push the branch to origin/{branch} after committing. -f Force the push to the repository -r REMOTE The name of the remote to push to. [origin] -b BRANCH Name of the branch to write to. [gh-pages] -s Use the shell when invoking Git. [False] -l Follow symlinks when adding files. [False] -h, --help show this help message and exit Its pretty simple. Inside your repository just run `ghp-import $DOCS_DIR` where `$DOCS_DIR` is the path to the **built** documentation. This will write a commit to your `gh-pages` branch with the current documents in it. If you specify `-p` it will also attempt to push the `gh-pages` branch to GitHub. By default it'll just run `git push origin gh-pages`. You can specify a different remote using the `-r` flag. You can specify a different branch with `-b`. This is useful for user and organization page, which are served from the `master` branch. Some Windows users report needing to pass Git commands through the shell which can be accomplished by passing `-s`. The `-l` option will cause the import to follow symlinks for users that have odd configurations that include symlinking outside of their documentation directory. License ------- `ghp-import` is distributed under the Tumbolia Public License. See the LICENSE file for more information. Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 ghp-import-0.5.5/ghp_import.egg-info/SOURCES.txt0000644000076500000240000000040213054434062021743 0ustar davispstaff00000000000000LICENSE MANIFEST.in README.md ghp_import.py setup.py ghp_import.egg-info/PKG-INFO ghp_import.egg-info/SOURCES.txt ghp_import.egg-info/dependency_links.txt ghp_import.egg-info/entry_points.txt ghp_import.egg-info/not-zip-safe ghp_import.egg-info/top_level.txtghp-import-0.5.5/ghp_import.egg-info/top_level.txt0000644000076500000240000000001313054434062022607 0ustar davispstaff00000000000000ghp_import ghp-import-0.5.5/ghp_import.py0000755000076500000240000001705113054434034016751 0ustar davispstaff00000000000000#! /usr/bin/env python # # This file is part of the ghp-import package released under # the Tumbolia Public License. See the LICENSE file for more # information. import errno import optparse as op import os import subprocess as sp import sys import time import unicodedata __usage__ = "%prog [OPTIONS] DIRECTORY" if sys.version_info[0] == 3: def enc(text): if isinstance(text, bytes): return text return text.encode() def dec(text): if isinstance(text, bytes): return text.decode('utf-8') return text def write(pipe, data): try: pipe.stdin.write(data) except IOError as e: if e.errno != errno.EPIPE: raise else: def enc(text): if isinstance(text, unicode): return text.encode('utf-8') return text def dec(text): if isinstance(text, unicode): return text return text.decode('utf-8') def write(pipe, data): pipe.stdin.write(data) class Git(object): def __init__(self, use_shell=False): self.use_shell = use_shell self.cmd = None self.pipe = None self.stderr = None self.stdout = None def check_repo(self, parser): if self.call('rev-parse') != 0: error = self.stderr if not error: error = "Unknown Git error" error = dec(error) if error.startswith("fatal: "): error = error[len("fatal: "):] parser.error(error) def try_rebase(self, remote, branch): rc = self.call('rev-list', '--max-count=1', '%s/%s' % (remote, branch)) if rc != 0: return True rev = dec(self.stdout.strip()) rc = self.call('update-ref', 'refs/heads/%s' % branch, rev) if rc != 0: return False return True def get_config(self, key): self.call('config', key) return self.stdout.strip() def get_prev_commit(self, branch): rc = self.call('rev-list', '--max-count=1', branch, '--') if rc != 0: return None return dec(self.stdout).strip() def open(self, *args, **kwargs): self.cmd = ['git'] + list(args) if sys.version_info >= (3, 2, 0): kwargs['universal_newlines'] = False for k in 'stdin stdout stderr'.split(): kwargs[k] = sp.PIPE kwargs['shell'] = self.use_shell self.pipe = sp.Popen(self.cmd, **kwargs) return self.pipe def call(self, *args, **kwargs): self.open(*args, **kwargs) (self.stdout, self.stderr) = self.pipe.communicate() return self.pipe.wait() def check_call(self, *args, **kwargs): kwargs["shell"] = self.use_shell sp.check_call(['git'] + list(args), **kwargs) def normalize_path(path): # Fix unicode pathnames on OS X # See: http://stackoverflow.com/a/5582439/44289 if sys.platform == "darwin": return unicodedata.normalize("NFKC", dec(path)) return path def mk_when(timestamp=None): if timestamp is None: timestamp = int(time.time()) currtz = time.strftime('%z') return "%s %s" % (timestamp, currtz) def start_commit(pipe, git, branch, message): uname = dec(git.get_config("user.name")) email = dec(git.get_config("user.email")) write(pipe, enc('commit refs/heads/%s\n' % branch)) write(pipe, enc('committer %s <%s> %s\n' % (uname, email, mk_when()))) write(pipe, enc('data %d\n%s\n' % (len(enc(message)), message))) head = git.get_prev_commit(branch) if head: write(pipe, enc('from %s\n' % head)) write(pipe, enc('deleteall\n')) def add_file(pipe, srcpath, tgtpath): with open(srcpath, "rb") as handle: if os.access(srcpath, os.X_OK): write(pipe, enc('M 100755 inline %s\n' % tgtpath)) else: write(pipe, enc('M 100644 inline %s\n' % tgtpath)) data = handle.read() write(pipe, enc('data %d\n' % len(data))) write(pipe, enc(data)) write(pipe, enc('\n')) def add_nojekyll(pipe): write(pipe, enc('M 100644 inline .nojekyll\n')) write(pipe, enc('data 0\n')) write(pipe, enc('\n')) def add_cname(pipe, cname): write(pipe, enc('M 100644 inline CNAME\n')) write(pipe, enc('data %d\n%s\n' % (len(enc(cname)), cname))) def gitpath(fname): norm = os.path.normpath(fname) return "/".join(norm.split(os.path.sep)) def run_import(git, srcdir, opts): cmd = ['git', 'fast-import', '--date-format=raw', '--quiet'] kwargs = { "stdin": sp.PIPE, "shell": opts.use_shell } if sys.version_info >= (3, 2, 0): kwargs["universal_newlines"] = False pipe = sp.Popen(cmd, **kwargs) start_commit(pipe, git, opts.branch, opts.mesg) for path, dnames, fnames in os.walk(srcdir, followlinks=opts.followlinks): for fn in fnames: fpath = os.path.join(path, fn) fpath = normalize_path(fpath) gpath = gitpath(os.path.relpath(fpath, start=srcdir)) add_file(pipe, fpath, gpath) if opts.nojekyll: add_nojekyll(pipe) if opts.cname is not None: add_cname(pipe, opts.cname) write(pipe, enc('\n')) pipe.stdin.close() if pipe.wait() != 0: sys.stdout.write(enc("Failed to process commit.\n")) def options(): return [ op.make_option('-n', '--no-jekyll', dest='nojekyll', default=False, action="store_true", help='Include a .nojekyll file in the branch.'), op.make_option('-c', '--cname', dest='cname', default=None, help='Write a CNAME file with the given CNAME.'), op.make_option('-m', '--message', dest='mesg', default='Update documentation', help='The commit message to use on the target branch.'), op.make_option('-p', '--push', dest='push', default=False, action='store_true', help='Push the branch to origin/{branch} after committing.'), op.make_option('-f', '--force', dest='force', default=False, action='store_true', help='Force the push to the repository'), op.make_option('-r', '--remote', dest='remote', default='origin', help='The name of the remote to push to. [%default]'), op.make_option('-b', '--branch', dest='branch', default='gh-pages', help='Name of the branch to write to. [%default]'), op.make_option('-s', '--shell', dest='use_shell', default=False, action='store_true', help='Use the shell when invoking Git. [%default]'), op.make_option('-l', '--follow-links', dest='followlinks', default=False, action='store_true', help='Follow symlinks when adding files. [%default]') ] def main(): parser = op.OptionParser(usage=__usage__, option_list=options()) opts, args = parser.parse_args() if len(args) == 0: parser.error("No import directory specified.") if len(args) > 1: parser.error("Unknown arguments specified: %s" % ', '.join(args[1:])) if not os.path.isdir(args[0]): parser.error("Not a directory: %s" % args[0]) git = Git(use_shell=opts.use_shell) git.check_repo(parser) if not git.try_rebase(opts.remote, opts.branch): parser.error("Failed to rebase %s branch." % opts.branch) run_import(git, args[0], opts) if opts.push: if opts.force: git.check_call('push', opts.remote, opts.branch, '--force') else: git.check_call('push', opts.remote, opts.branch) if __name__ == '__main__': main() ghp-import-0.5.5/LICENSE0000644000076500000240000000056313025021164015223 0ustar davispstaff00000000000000 Tumbolia Public License Copyright 2013, Paul Davis Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. opan saurce LOL ghp-import-0.5.5/MANIFEST.in0000644000076500000240000000004213025021164015744 0ustar davispstaff00000000000000include LICENSE include README.md ghp-import-0.5.5/PKG-INFO0000644000076500000240000001130213054434062015313 0ustar davispstaff00000000000000Metadata-Version: 1.1 Name: ghp-import Version: 0.5.5 Summary: Copy your docs directly to the gh-pages branch. Home-page: http://github.com/davisp/ghp-import Author: Paul Joseph Davis Author-email: paul.joseph.davis@gmail.com License: Tumbolia Public License Description: GitHub Pages Import =================== As part of [gunicorn][gunicorn], [Benoit Chesneau][benoit] and I have been starting to look at how to host documentation. There's the obvious method of using [GitHub's post-receive hook][github-post] to trigger doc builds and rsync to a webserver, but we ended up wanting to try out github's hosting to make the whole interface a bit more robust. [GitHub Pages][gh-pages] is a pretty awesome service that GitHub provides for hosting project documentation. The only thing is that it requires a `gh-pages` branch that is the site's document root. This means that keeping documentation sources in the branch with code is a bit difficult. And it really turns into a head scratcher for things like [Sphinx][sphinx] that want to access documentation sources and code sources at the same time. Then I stumbled across an interesting looking package called [github-tools][github-tools] that looked almost like what I wanted. It was a tad complicated and more involved than I wanted but it gave me an idear. Why not just write a script that can copy a directory to the `gh-pages` branch of the repository. This saves me from even having to think about the branch and everything becomes magical. This is what `ghp-import` was written for. [gunicorn]: http://www.gunicorn.com/ "Gunicorn" [benoit]: http://github.com/benoitc "Benoît Chesneau" [github-post]: https://help.github.com/articles/post-receive-hooks "GitHub Post-Receive Hook" [gh-pages]: http://pages.github.com/ "GitHub Pages" [sphinx]: http://sphinx.pocoo.org/ "Sphinx Documentation" [github-tools]: http://dinoboff.github.com/github-tools/ "github-tools" Big Fat Warning --------------- This will **DESTROY** your `gh-pages` branch. If you love it, you'll want to take backups before playing with this. This script assumes that `gh-pages` is 100% derivative. You should never edit files in your `gh-pages` branch by hand if you're using this script because you will lose your work. Usage ----- Usage: ghp-import [OPTIONS] DIRECTORY Options: -n Include a .nojekyll file in the branch. -c CNAME Write a CNAME file with the given CNAME. -m MESG The commit message to use on the target branch. -p Push the branch to origin/{branch} after committing. -f Force the push to the repository -r REMOTE The name of the remote to push to. [origin] -b BRANCH Name of the branch to write to. [gh-pages] -s Use the shell when invoking Git. [False] -l Follow symlinks when adding files. [False] -h, --help show this help message and exit Its pretty simple. Inside your repository just run `ghp-import $DOCS_DIR` where `$DOCS_DIR` is the path to the **built** documentation. This will write a commit to your `gh-pages` branch with the current documents in it. If you specify `-p` it will also attempt to push the `gh-pages` branch to GitHub. By default it'll just run `git push origin gh-pages`. You can specify a different remote using the `-r` flag. You can specify a different branch with `-b`. This is useful for user and organization page, which are served from the `master` branch. Some Windows users report needing to pass Git commands through the shell which can be accomplished by passing `-s`. The `-l` option will cause the import to follow symlinks for users that have odd configurations that include symlinking outside of their documentation directory. License ------- `ghp-import` is distributed under the Tumbolia Public License. See the LICENSE file for more information. Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 ghp-import-0.5.5/README.md0000644000076500000240000000676513025557451015524 0ustar davispstaff00000000000000GitHub Pages Import =================== As part of [gunicorn][gunicorn], [Benoit Chesneau][benoit] and I have been starting to look at how to host documentation. There's the obvious method of using [GitHub's post-receive hook][github-post] to trigger doc builds and rsync to a webserver, but we ended up wanting to try out github's hosting to make the whole interface a bit more robust. [GitHub Pages][gh-pages] is a pretty awesome service that GitHub provides for hosting project documentation. The only thing is that it requires a `gh-pages` branch that is the site's document root. This means that keeping documentation sources in the branch with code is a bit difficult. And it really turns into a head scratcher for things like [Sphinx][sphinx] that want to access documentation sources and code sources at the same time. Then I stumbled across an interesting looking package called [github-tools][github-tools] that looked almost like what I wanted. It was a tad complicated and more involved than I wanted but it gave me an idear. Why not just write a script that can copy a directory to the `gh-pages` branch of the repository. This saves me from even having to think about the branch and everything becomes magical. This is what `ghp-import` was written for. [gunicorn]: http://www.gunicorn.com/ "Gunicorn" [benoit]: http://github.com/benoitc "Benoît Chesneau" [github-post]: https://help.github.com/articles/post-receive-hooks "GitHub Post-Receive Hook" [gh-pages]: http://pages.github.com/ "GitHub Pages" [sphinx]: http://sphinx.pocoo.org/ "Sphinx Documentation" [github-tools]: http://dinoboff.github.com/github-tools/ "github-tools" Big Fat Warning --------------- This will **DESTROY** your `gh-pages` branch. If you love it, you'll want to take backups before playing with this. This script assumes that `gh-pages` is 100% derivative. You should never edit files in your `gh-pages` branch by hand if you're using this script because you will lose your work. Usage ----- Usage: ghp-import [OPTIONS] DIRECTORY Options: -n Include a .nojekyll file in the branch. -c CNAME Write a CNAME file with the given CNAME. -m MESG The commit message to use on the target branch. -p Push the branch to origin/{branch} after committing. -f Force the push to the repository -r REMOTE The name of the remote to push to. [origin] -b BRANCH Name of the branch to write to. [gh-pages] -s Use the shell when invoking Git. [False] -l Follow symlinks when adding files. [False] -h, --help show this help message and exit Its pretty simple. Inside your repository just run `ghp-import $DOCS_DIR` where `$DOCS_DIR` is the path to the **built** documentation. This will write a commit to your `gh-pages` branch with the current documents in it. If you specify `-p` it will also attempt to push the `gh-pages` branch to GitHub. By default it'll just run `git push origin gh-pages`. You can specify a different remote using the `-r` flag. You can specify a different branch with `-b`. This is useful for user and organization page, which are served from the `master` branch. Some Windows users report needing to pass Git commands through the shell which can be accomplished by passing `-s`. The `-l` option will cause the import to follow symlinks for users that have odd configurations that include symlinking outside of their documentation directory. License ------- `ghp-import` is distributed under the Tumbolia Public License. See the LICENSE file for more information. ghp-import-0.5.5/setup.cfg0000644000076500000240000000007313054434062016042 0ustar davispstaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 ghp-import-0.5.5/setup.py0000644000076500000240000000211313054434034015727 0ustar davispstaff00000000000000import io import os import sys try: from setuptools import setup except ImportError: from distutils.core import setup LONG_DESC_PATH = os.path.join(os.path.dirname(__file__), "README.md") LONG_DESC = io.open(LONG_DESC_PATH, encoding = "utf-8").read() setup( name = "ghp-import", version = "0.5.5", description = "Copy your docs directly to the gh-pages branch.", long_description = LONG_DESC, author = "Paul Joseph Davis", author_email = "paul.joseph.davis@gmail.com", license = "Tumbolia Public License", url = "http://github.com/davisp/ghp-import", zip_safe = False, classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", 'Natural Language :: English', "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", ], py_modules = ["ghp_import"], entry_points = { "console_scripts": [ "ghp-import = ghp_import:main", ], } )