code: public String getScmBranch()
          throws MojoExecutionException
      {
          try
          {
              ScmRepository repository = getScmRepository();
              ScmProvider provider = scmManager.getProviderByRepository( repository );
              /* git branch can be obtained directly by a command */
              if ( GitScmProviderRepository.PROTOCOL_GIT.equals( provider.getScmType() ) )
              {
                  ScmFileSet fileSet = new ScmFileSet( scmDirectory );
                  return GitBranchCommand.getCurrentBranch( getLogger(),
                                                            (GitScmProviderRepository) repository.getProviderRepository(),
                                                            fileSet );
              }
              else if ( provider instanceof HgScmProvider )
              {
                  /* hg branch can be obtained directly by a command */
                  HgOutputConsumer consumer = new HgOutputConsumer( getLogger() );
                  ScmResult result = HgUtils.execute( consumer, logger, scmDirectory, new String[] { "id", "-b" } );
                  checkResult( result );
                  if ( StringUtils.isNotEmpty( consumer.getOutput() ) )
                  {
                      return consumer.getOutput();
                  }
              }
          }
          catch ( ScmException e )
          {
              getLog().warn( "Cannot get the branch information from the git repository: \n" + e.getLocalizedMessage() );
          }
  
          return getScmBranchFromUrl();
      }
docs: Get the branch info for this revision from the repository. For svn, it is in svn info.
  
  @return
  @throws MojoExecutionException
  @throws MojoExecutionException