pypet/utils/gitintegration.py
def make_git_commit(environment, git_repository, user_message, git_fail):
    """ Makes a commit and returns if a new commit was triggered and the SHA_1 code of the commit.

    If `git_fail` is `True` program fails instead of triggering a new commit given
    not committed changes. Then a `GitDiffError` is raised.

    """

    # Import GitPython, we do it here to allow also users not having GitPython installed
    # to use the normal environment

    # Open the repository
    repo = git.Repo(git_repository)
    index = repo.index

    traj = environment.v_trajectory

    # Create the commit message and append the trajectory name and comment
    if traj.v_comment:
        commentstr = ', Comment: `%s`' % traj.v_comment
    else:
        commentstr = ''

    if user_message:
        user_message += ' -- '

    message = '%sTrajectory: `%s`, Time: `%s`, %s' % \
              (user_message, traj.v_name, traj.v_time, commentstr)

    # Detect changes:
    diff = index.diff(None)

    if diff:
        if git_fail:
            # User requested fail instead of a new commit
            raise pex.GitDiffError('Found not committed changes!')
        # Make the commit
        repo.git.add('-u')
        commit = index.commit(message)
        new_commit = True

    else:
        # Take old commit
        commit = repo.commit(None)
        new_commit = False

    # Add the commit info to the trajectory
    add_commit_variables(traj, commit)

    return new_commit, commit.hexsha
def make_git_commit(environment, git_repository, user_message, git_fail):
    """ Makes a commit and returns if a new commit was triggered and the SHA_1 code of the commit.

    If `git_fail` is `True` program fails instead of triggering a new commit given
    not committed changes. Then a `GitDiffError` is raised.

    """

    # Import GitPython, we do it here to allow also users not having GitPython installed
    # to use the normal environment

    # Open the repository
    repo = git.Repo(git_repository)
    index = repo.index

    traj = environment.v_trajectory

    # Create the commit message and append the trajectory name and comment
    if traj.v_comment:
        commentstr = ', Comment: `%s`' % traj.v_comment
    else:
        commentstr = ''

    if user_message:
        user_message += ' -- '

    message = '%sTrajectory: `%s`, Time: `%s`, %s' % \
              (user_message, traj.v_name, traj.v_time, commentstr)

    # Detect changes:
    diff = index.diff(None)

    if diff:
        if git_fail:
            # User requested fail instead of a new commit
            raise pex.GitDiffError('Found not committed changes!')
        # Make the commit
        repo.git.add('-u')
        commit = index.commit(message)
        new_commit = True

    else:
        # Take old commit
        commit = repo.commit(None)
        new_commit = False

    # Add the commit info to the trajectory
    add_commit_variables(traj, commit)

    return new_commit, commit.hexsha
def make_git_commit ( environment , git_repository , user_message , git_fail ) : # Import GitPython, we do it here to allow also users not having GitPython installed # to use the normal environment # Open the repository repo = git . Repo ( git_repository ) index = repo . index traj = environment . v_trajectory # Create the commit message and append the trajectory name and comment if traj . v_comment : commentstr = ', Comment: `%s`' % traj . v_comment else : commentstr = '' if user_message : user_message += ' -- ' message = '%sTrajectory: `%s`, Time: `%s`, %s' % ( user_message , traj . v_name , traj . v_time , commentstr ) # Detect changes: diff = index . diff ( None ) if diff : if git_fail : # User requested fail instead of a new commit raise pex . GitDiffError ( 'Found not committed changes!' ) # Make the commit repo . git . add ( '-u' ) commit = index . commit ( message ) new_commit = True else : # Take old commit commit = repo . commit ( None ) new_commit = False # Add the commit info to the trajectory add_commit_variables ( traj , commit ) return new_commit , commit . hexsha
Makes a commit and returns if a new commit was triggered and the SHA_1 code of the commit.

    If `git_fail` is `True` program fails instead of triggering a new commit given
    not committed changes. Then a `GitDiffError` is raised.
Makes a commit and returns if a new commit was triggered and the SHA_1 code of the commit .