# encoding: utf-8

import os
import sys
from sh import git, pwd, sh
from workflow import Workflow, ICON_SYNC, web


def main(wf):
    return_value = 0

    if not repo_exists():
        return_value = clone_repo()
    else:
        return_value = pull_repo()

    if return_value:
        print "ERROR. Templates could not be downloaded."
    else:
        print "Templates have been successfully updated."


def clone_repo():
    return_value = 0

    try:
        return_value = git.clone("https://github.com/github/gitignore.git")
    except:
        return_value = -1

    return return_value


def pull_repo():
    return_value = 0

    try:
        os.chdir("./gitignore")
        return_code = git.pull()
    except:
        return_value = -1

    return return_value


def repo_exists():
    return os.path.isdir("./gitignore")


if __name__ == u"__main__":
    wf = Workflow()
    sys.exit(wf.run(main))

Add script that downloads templates
Add script that downloads templates

A script has been added to download the templates from GitHub. The
templates are checked out as a Git repository, making it really easy to
download changes later on.

If the repository does not exist yet, "git clone" is executed to create
a local copy of the it. If it exists, "git pull" is invoked to get the
latest version of the templates.
