michael-o closed pull request #42: Fix maven-scm-provider-jgit provider
scmVersionType=revision checkout.
URL: https://github.com/apache/maven-scm/pull/42
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java
index 8d4931b1e..ab39e579b 100644
---
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java
+++
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java
@@ -23,6 +23,7 @@
import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmRevision;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
@@ -129,13 +130,15 @@ protected CheckOutScmResult executeCheckOutCommand(
ScmProviderRepository repo,
// git repo exists, so we must git-pull the changes
CredentialsProvider credentials = JGitUtils.prepareSession(
getLogger(), git, repository );
- if ( version != null && StringUtils.isNotEmpty(
version.getName() ) && ( version instanceof ScmTag ) )
+ if ( version != null && StringUtils.isNotEmpty(
version.getName() ) && ( version instanceof ScmTag
+ || version instanceof ScmRevision ) )
{
// A tag will not be pulled but we only fetch all the
commits from the upstream repo
// This is done because checking out a tag might not
happen on the current branch
// but create a 'detached HEAD'.
// In fact, a tag in git may be in multiple branches. This
occurs if
// you create a branch after the tag has been created
+ // revision checkout also creates a 'detached HEAD'
getLogger().debug( "fetch..." );
git.fetch().setCredentialsProvider( credentials
).setProgressMonitor( monitor ).call();
}
@@ -157,6 +160,11 @@ else if ( localBranchNames.contains( branch ) )
getLogger().info( "checkout [" + branch + "] at " +
fileSet.getBasedir() );
git.checkout().setName( branch ).call();
}
+ else if ( version instanceof ScmRevision )
+ {
+ getLogger().info( "checkout revision [" + branch + "] at " +
fileSet.getBasedir() );
+ git.checkout().setName( branch ).call();
+ }
else
{
getLogger().info( "checkout remote branch [" + branch + "] at
" + fileSet.getBasedir() );
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services