Exemplo n.º 1
0
Arquivo: gitdb.py Projeto: cb22/gitdb
def prepare_commit_msg(branch, database, msgfile):
    """\
    The prepare-commit-message hook. We get called with an additional parameter,
    the path to the commit message that will be displayed to the user.
    """
    pending_patch = get_pending_patch(branch, database)
    if pending_patch:
        with open(msgfile, "a") as msg_file:
            msg_file.write("\n\n")
            msg_file.write("# SQL Changes will be included with this commit.\n")
Exemplo n.º 2
0
Arquivo: gitdb.py Projeto: cb22/gitdb
def commit_msg(branch, database, msgfile):
    """\
    The commit-msg hook. We are called after the message has been set. We need
    to check if the commit has been accepted - if so, continue. Otherwise, cleanup
    after ourselves.
    """
    with open(msgfile, "r") as msg_file:
        non_comment_lines = [line for line in msg_file.readlines() if not line.startswith("#") and line != "\n"]
    pending_patch = get_pending_patch(branch, database)
    if pending_patch:
        if len(non_comment_lines) == 0:
            logging.info("Empty commit message was given, cleaning up SQL files...")
            clean_pending(branch, database)
        else:
            logging.info("Valid commit message. Saving status database and cleaning indications.")
            if branch == "master":
                logging.debug("Working on master branch...")
                add_patch_to_db(branch, database, os.path.join("sql", "development", database, os.path.basename(pending_patch)))
            else:
                logging.debug("Working on local branch...")
                dest = os.path.join(".git", "gitdb", "patches", branch, database, os.path.basename(pending_patch))
                os.rename(pending_patch, dest)
                add_patch_to_db(branch, database, dest)
            clean_pending(branch, database, use_git=False)