fix add files
Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/cbfaadc2 Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/cbfaadc2 Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/cbfaadc2 Branch: refs/heads/master Commit: cbfaadc2711f9feea8050b6b71b1c453c9e8fa55 Parents: 7b064c5 Author: Olivier Lamy <ol...@apache.org> Authored: Sat Jun 29 22:16:56 2013 +1000 Committer: Olivier Lamy <ol...@apache.org> Committed: Sat Jun 29 22:16:56 2013 +1000 ---------------------------------------------------------------------- .../scm/provider/git/jgit/command/JGitUtils.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-scm/blob/cbfaadc2/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java b/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java index 42fcb70..2ed8eda 100644 --- a/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java +++ b/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java @@ -204,7 +204,7 @@ public class JGitUtils /** * Translate a {@code FileStatus} in the matching {@code ScmFileStatus}. * - * @param status + * @param changeType * @return the matching ScmFileStatus * @throws ScmException if the given Status cannot be translated */ @@ -234,7 +234,7 @@ public class JGitUtils * @param git the repo to add the files to * @param fileSet the set of files within the workspace, the files are added * relative to the basedir of this fileset - * @return a list of files changed + * @return a list of added files * @throws GitAPIException * @throws NoFilepatternException */ @@ -245,7 +245,13 @@ public class JGitUtils AddCommand add = git.add(); for ( File file : fileSet.getFileList() ) { - if ( file.exists() ) + File scmFile = file; + if (!file.isAbsolute()) + { + scmFile = new File( fileSet.getBasedir().getPath(), file.getPath() ); + } + + if ( scmFile.exists() ) { String path = relativize( baseUri, file ); add.addFilepattern( path ); @@ -254,14 +260,14 @@ public class JGitUtils add.call(); Status status = git.status().call(); - Set<String> changed = status.getChanged(); + Set<String> added = status.getAdded(); List<ScmFile> changedFiles = new ArrayList<ScmFile>(); // rewrite all detected files to now have status 'checked_in' - for ( String entry : changed ) + for ( String entry : added ) { - ScmFile scmfile = new ScmFile( entry, ScmFileStatus.MODIFIED ); + ScmFile scmfile = new ScmFile( entry, ScmFileStatus.ADDED ); // if a specific fileSet is given, we have to check if the file is // really tracked