def get_scm():
 global _SCM
 if (not _SCM):
  from pants.scm.git import Git
  worktree = Git.detect_worktree()
  if (worktree and os.path.isdir(worktree)):
   git = Git(worktree=worktree)
   try:
    logger.debug(u'Detected git repository at {} on branch {}'.format(worktree, git.branch_name))
    set_scm(git)
   except git.LocalException as e:
    logger.info(u'Failed to load git repository at {}: {}'.format(worktree, e))
 return _SCM

def get_scm ( ) : global _SCM if ( not _SCM ) : from pants . scm . git import Git worktree = Git . detect_worktree ( ) if ( worktree and os . path . isdir ( worktree ) ) : git = Git ( worktree = worktree ) try : logger . debug ( u'Detected git repository at {} on branch {}' . format ( worktree , git . branch_name ) ) set_scm ( git ) except git . LocalException as e : logger . info ( u'Failed to load git repository at {}: {}' . format ( worktree , e ) ) return _SCM
returns the pants scm if any .