[ 
http://jira.codehaus.org/browse/MOJO-1199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=230305#action_230305
 ] 

Andrew Phillips commented on MOJO-1199:
---------------------------------------

There is an additional problem with the way the plugin handles updates (i.e. 
when doUpdate=true). Due to the way ScmProvider.update is called, the update 
command is always

  git pull origin master

and not

  git pull origin <current-branch>

which can leave your master pretty messed-up if it's not up-to-date and doesn't 
appear to match the intended semantics of checking whether what is currently 
being built is up-to-date.

Specifically, CreateMojo.update [1] will, in line 564, call

  scmProvider.update(repository, new ScmFileSet(scmDirectory));

Following that call through the maven-scm-api shows that this results (in 
AbstractScmProvider [2]) in the call 

  update(repository, fileSet, (ScmVersion) null, true );

i.e. an update with a null version. That, in turn, eventually bottoms out in 
the gitexe provider's GitUpdateCommand [3], and there in createCommandLine ends 
up at

  // now set the branch where we would like to pull from
  if ( scmVersion instanceof ScmBranch ) {
    cl.createArg().setLine( scmVersion.getName() );
  } else {
    cl.createArg().setLine( "master" );
  }            

The null scmVersion then causes the

  git pull origin master

line.

A patch for this problem is attached and will hopefully soon be added to Antony 
Stubbs' fork [4] (see above comment).

[1] 
http://github.com/astubbs/buildnumber-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/build/CreateMojo.java
[2] 
https://grid.sonatype.org/ci/job/maven-scm/ws/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java/*view*/
[3] 
https://grid.sonatype.org/ci/job/maven-scm/ws/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitUpdateCommand.java/*view*/
[4] http://github.com/astubbs/buildnumber-maven-plugin

> Build number plugin to support GIT SCM
> --------------------------------------
>
>                 Key: MOJO-1199
>                 URL: http://jira.codehaus.org/browse/MOJO-1199
>             Project: Mojo
>          Issue Type: Improvement
>          Components: buildnumber
>            Reporter: Nigel Magnay
>         Attachments: 0001-Add-GIT-support-for-build-numbering.patch, 
> 0001-Support-GIT-revision-numbers.patch, buildnumber-git-support.patch, 
> update-from-current-branch.patch
>
>
> The build number plugin assumes that SVN is being used.
> It would be nice to support GIT as this creates SHA1 revision numbers.
> Attached is a patch to do this - the pom.xml will need to be adjusted to use 
> the GIT SCM revision from maven when it is released.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to