コード例 #1
0
ファイル: test_gbpx.py プロジェクト: johwerm/gbpx
def set_up():
    # Init repository with one file.
    remove_dir(_FLAGS, _TEST_DIR)
    mkdirs(_FLAGS, _TEST_DIR)
    init_repository(_FLAGS, _TEST_DIR)
    chdir(_TEST_DIR)
    create_file(_FLAGS, _TEST_FILE)
    commit_changes(_FLAGS, "Test file added.")

    # Create branches.
    create_branch(_FLAGS, _UPSTREAM)
    switch_branch(_UPSTREAM)

    create_branch(_FLAGS, _DEBIAN)
    switch_branch(_DEBIAN)
    mkdirs(_FLAGS, path.dirname(_TEST_DEBIAN_FILE))
    create_file(_FLAGS, _TEST_DEBIAN_FILE)
    commit_changes(_FLAGS, "Test debian file added.")

    # Commit ignored file and config.
    switch_branch(_RELEASE)
    create_file(_FLAGS, _IGNORE_FILE)
    create_file(_FLAGS, _TEST_FILE2)
    execute_with(action=Action.CONFIG)
    commit_changes(_FLAGS, "Ignored file added.")
コード例 #2
0
ファイル: gbpxutil.py プロジェクト: johwerm/gbpx
def add_backup(flags, bak_dir, name="unknown"):
    """
    Adds a backup of the git repository.
    - bak_dir   -- The destination directory.
    - name      -- The name of the backup, replaces '_' with '-'.
    Returns the name of the created backup file.
    """
    try:
        check_git_rep()

        # Make sure there are no '_' in the name.
        name.replace('_', '-')

        # Set the path to the new backup file.
        tar_name = "{0}_{1}{2}".format(name,
                                       strftime(_BAK_FILE_DATE_FORMAT),
                                       _BAK_FILE_EXT)
        tar_path = path.join(bak_dir, tar_name)

        # Make a safety backup of the current git repository.
        log(flags, "Creating backup file \'" + tar_path + "\'")
        if not flags[Flag.SAFEMODE]:
            mkdirs(flags, bak_dir)
            exec_cmd(["tar", "-czf", tar_path, "."])

        return tar_name
    except Error as err:
        log(flags, "Could not add backup in \'" + bak_dir + "\'")
        raise OpError(err)