lama/common.py
def git_log() -> str:
    """
    Get the git branch and commit for logging.
    This info is in the current_commit file, which is written to after each commit using opst-commit hook.

    Returns
    -------
    the git branch, commit, and message
    """
    this_dir = Path(__file__).parent.resolve()
    git_msg_file = this_dir / 'current_commit1'

    try:
        msg = ''
        with open(git_msg_file, 'r') as fh:
            for line in fh:
                msg += line
    except OSError:
        # current_commit file does not exist (This would come from pip install).
        # So try using git
        if git:
            try:
                this_module = Path(__file__).parent
                repo = git.Repo(search_parent_directories=True, path=this_module)
                sha = repo.head.object.hexsha[:7]
                msg = f'Git commit: {sha}'
            # Kyle -if the git commit can not be determined, for example
            # running python3 setup.py install --user installs into site packages
            # stuffing the git commit up - you get the error below and stops LAMA
            # from running - hence the extra try except
            except git.exc.InvalidGitRepositoryError:
                pass
    if not msg:
        msg = f'Cannot determine git commit'

    return msg

    Get the git branch and commit for logging.
    This info is in the current_commit file, which is written to after each commit using opst-commit hook.

    Returns
    -------
    the git branch, commit, and message
    
Get the git branch and commit for logging.
This info is in the current_commit file, which is written to after each commit using opst-commit hook.

Returns

the git branch, commit, and message
Get the git branch and commit for logging . This info is in the current_commit file which is written to after each commit using opst - commit hook . Returns the git branch commit and message
def git_log() -> str:
    this_dir = Path(__file__).parent.resolve()
    git_msg_file = this_dir / 'current_commit1'
    try:
        msg = ''
        with open(git_msg_file, 'r') as fh:
            for line in fh:
                msg += line
    except OSError:
        if git:
            try:
                this_module = Path(__file__).parent
                repo = git.Repo(search_parent_directories=True, path=this_module)
                sha = repo.head.object.hexsha[:7]
                msg = f'Git commit: {sha}'
            except git.exc.InvalidGitRepositoryError:
                pass
    if not msg:
        msg = f'Cannot determine git commit'
    return msg
def git_log ( ) -> str : this_dir = Path ( __file__ ) . parent . resolve ( ) git_msg_file = this_dir / 'current_commit1' try : msg = '' with open ( git_msg_file , 'r' ) as fh : for line in fh : msg += line except OSError : if git : try : this_module = Path ( __file__ ) . parent repo = git . Repo ( search_parent_directories = True , path = this_module ) sha = repo . head . object . hexsha [ : 7 ] msg = f'Git commit: {sha}' except git . exc . InvalidGitRepositoryError : pass if not msg : msg = f'Cannot determine git commit' return msg
Get the git branch and commit for logging.
Get the git branch and commit for logging .
"""
    Get the git branch and commit for logging.
    This info is in the current_commit file, which is written to after each commit using opst-commit hook.

    Returns
    -------
    the git branch, commit, and message
    """ # current_commit file does not exist (This would come from pip install). # So try using git # Kyle -if the git commit can not be determined, for example # running python3 setup.py install --user installs into site packages # stuffing the git commit up - you get the error below and stops LAMA # from running - hence the extra try except