(cls, location)
return None
Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
Return the current branch or None if HEAD isn t at a branch ( e . g . detached HEAD ) .
def get_current_branch(cls, location):
        """
        Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
        """
        # git-symbolic-ref exits with empty stdout if "HEAD" is a detached
        # HEAD rather than a symbolic ref.  In addition, the -q causes the
        # command to exit with status code 1 instead of 128 in this case
        # and to suppress the message to stderr.
        args = ['symbolic-ref', '-q', 'HEAD']
        output = cls.run_command(
            args, extra_ok_returncodes=(1, ), show_stdout=False, cwd=location,
        )
        ref = output.strip()

        if ref.startswith('refs/heads/'):
            return ref[len('refs/heads/'):]

        return None
def get_current_branch ( cls , location ) : # git-symbolic-ref exits with empty stdout if "HEAD" is a detached # HEAD rather than a symbolic ref.  In addition, the -q causes the # command to exit with status code 1 instead of 128 in this case # and to suppress the message to stderr. args = [ 'symbolic-ref' , '-q' , 'HEAD' ] output = cls . run_command ( args , extra_ok_returncodes = ( 1 , ) , show_stdout = False , cwd = location , ) ref = output . strip ( ) if ref . startswith ( 'refs/heads/' ) : return ref [ len ( 'refs/heads/' ) : ] return None