class UIGit extends VCS implements IVCS {

  @Override
  public String getBranch() {
    try {
      Ref head = git.getRepository().exactRef( Constants.HEAD );
      String branch = git.getRepository().getBranch();
      if ( head.getLeaf().getName().equals( Constants.HEAD ) ) { // if detached
        return Constants.HEAD + " detached at " + branch.substring( 0, 7 );
      } else {
        return branch;
      }
    } catch ( Exception e ) {
      return "";
    }
  }

}