Exemple #1
0
def checkout_handler(args):
    """
    Checkout a certain branch (usually a commitTag or master)

       checkout [domain] {branch_name}

       * domain is e.g. www.heise.de
       * branch_name the entity to checkout,
                     if omitted only the path is returned
                     and no git work is done

       * Returns: The Path to the checkout'd domain

       Note: You should always checkout master when you're done!
    """
    domain = args[0]
    domain_path = paths.get_domain_path(domain)

    if os.path.exists(domain_path) is False:
        raise ProtocolError('Invalid Domain.')

    try:
        branch = args[1]
    except IndexError:
        branch = None

    if branch is not None:
        wrapper = Git(domain)

        rcode = wrapper.checkout(branch)
        if rcode is not 0:
            raise ProtocolError('checkout returned {rc}'.format(rc=rcode))

    return domain_path + '\n'
Exemple #2
0
def commit_handler(args):
    """
    Make a commit on a certain domain:

       commit [domain] {message}

       * domain is e.g. www.heise.de
       * message is the commit message (optional, 'edit' by default)
       * Returns nothing (but OK or ACK ...)
    """
    domain = args[0]

    try:
        message = args[1]
    except IndexError:
        message = 'edit'

    wrapper = Git(domain)
    rcode = wrapper.commit(message)
    if rcode is not 0:
        raise ProtocolError('commit returned {rc}'.format(rc=rcode))