maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lothar Wendehals (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SCM-843) New files added to index are not checked in when nothing else has been changed in the working copy
Date Thu, 09 Feb 2017 13:47:41 GMT

     [ https://issues.apache.org/jira/browse/SCM-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lothar Wendehals updated SCM-843:
---------------------------------
    Description: 
Scenario:
Start with a clean working copy. Create a new file in the working copy and add it to the index.
Now run a checkin with JGitCheckinCommand. It will not commit the new file when nothing else
has changed (no modified file for example) in the working copy.

This is the original code in 1.9.5:

protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet,
String message, ScmVersion version) throws ScmException {
        Git git = null;
        try {
            File basedir = fileSet.getBasedir();
            git = JGitUtils.openRepo( basedir );

            boolean doCommit = false;

            if (!fileSet.getFileList().isEmpty()) {
                doCommit = JGitUtils.addAllFiles( git, fileSet ).size() > 0;
            }
            else {
                // add all tracked files which are modified manually
                Set<String> changeds = git.status().call().getModified();
                if ( changeds.isEmpty() ) {
                    // warn there is nothing to add
                    // here is the bug: status().call().getModified() does not return files
that have already been added to the index, it only returns files that have been modified but
not added to the index

                    getLogger().warn( "there are no files to be added" );
                    doCommit = false;
                }
                else {
                    AddCommand add = git.add();
                    for ( String changed : changeds ) {
                        getLogger().debug( "add manualy: " + changed );
                        add.addFilepattern( changed );
                        doCommit = true;
                    }
                    add.call();
                }
            }

            List<ScmFile> checkedInFiles = Collections.emptyList();
            if ( doCommit ) {
               ....
            }
            ...
    }

A possible fix would be:

if (!fileSet.getFileList().isEmpty()) {
     doCommit = JGitUtils.addAllFiles(git, fileSet).size() > 0;
} else {
     // Bugfix: Files that have been added in advance by
     // the user will not be committed if nothing else has changed.

     // add all tracked files which are modified manually
     Set<String> changeds = git.status().call().getModified();
     if (!changeds.isEmpty()) {
        AddCommand add = git.add();
        for (String changed : changeds) {
           getLogger().debug("add manually: " + changed);
           add.addFilepattern(changed);
           doCommit = true;
        }
       add.call();
    }

    Status status = git.status().call();
    doCommit = !status.getUncommittedChanges().isEmpty();
    if (!doCommit) {
      getLogger().warn("there are no files to commit");
    }
 }
 List<ScmFile> checkedInFiles = Collections.emptyList();
 if (doCommit) {
   ...


  was:
Scenario:
Start with a clean working copy. Create a new file in the working copy and add it to the index.
Now run a checkin with JGitCheckinCommand. It will not commit the new file when nothing else
has changed (no modified file for example) in the working copy.

This is the original code in 1.9.5:

protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet,
String message, ScmVersion version) throws ScmException {
        Git git = null;
        try {
            File basedir = fileSet.getBasedir();
            git = JGitUtils.openRepo( basedir );

            boolean doCommit = false;

            if (!fileSet.getFileList().isEmpty()) {
                doCommit = JGitUtils.addAllFiles( git, fileSet ).size() > 0;
            }
            else {
                // add all tracked files which are modified manually
                Set<String> changeds = git.status().call().getModified();
                if ( changeds.isEmpty() ) {
                    // warn there is nothing to add
                    // here is the bug: status().call().getModified() does not return files
that have already been added to the index, it only returns files that have been modified but
not added to the index
                    getLogger().warn( "there are no files to be added" );
                    doCommit = false;
                }
                else {
                    AddCommand add = git.add();
                    for ( String changed : changeds ) {
                        getLogger().debug( "add manualy: " + changed );
                        add.addFilepattern( changed );
                        doCommit = true;
                    }
                    add.call();
                }
            }

            List<ScmFile> checkedInFiles = Collections.emptyList();
            if ( doCommit ) {
               ....
            }
            ...
    }

A possible fix would be:

if (!fileSet.getFileList().isEmpty()) {
     doCommit = JGitUtils.addAllFiles(git, fileSet).size() > 0;
} else {
     // Bugfix: Files that have been added in advance by
     // the user will not be committed if nothing else has changed.

     // add all tracked files which are modified manually
     Set<String> changeds = git.status().call().getModified();
     if (!changeds.isEmpty()) {
        AddCommand add = git.add();
        for (String changed : changeds) {
           getLogger().debug("add manually: " + changed);
           add.addFilepattern(changed);
           doCommit = true;
        }
       add.call();
    }

    Status status = git.status().call();
    doCommit = !status.getUncommittedChanges().isEmpty();
    if (!doCommit) {
      getLogger().warn("there are no files to commit");
    }
 }
 List<ScmFile> checkedInFiles = Collections.emptyList();
 if (doCommit) {
   ...



> New files added to index are not checked in when nothing else has been changed in the
working copy
> --------------------------------------------------------------------------------------------------
>
>                 Key: SCM-843
>                 URL: https://issues.apache.org/jira/browse/SCM-843
>             Project: Maven SCM
>          Issue Type: Bug
>          Components: maven-scm-provider-jgit
>    Affects Versions: 1.9.5
>            Reporter: Lothar Wendehals
>
> Scenario:
> Start with a clean working copy. Create a new file in the working copy and add it to
the index. Now run a checkin with JGitCheckinCommand. It will not commit the new file when
nothing else has changed (no modified file for example) in the working copy.
> This is the original code in 1.9.5:
> protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet
fileSet, String message, ScmVersion version) throws ScmException {
>         Git git = null;
>         try {
>             File basedir = fileSet.getBasedir();
>             git = JGitUtils.openRepo( basedir );
>             boolean doCommit = false;
>             if (!fileSet.getFileList().isEmpty()) {
>                 doCommit = JGitUtils.addAllFiles( git, fileSet ).size() > 0;
>             }
>             else {
>                 // add all tracked files which are modified manually
>                 Set<String> changeds = git.status().call().getModified();
>                 if ( changeds.isEmpty() ) {
>                     // warn there is nothing to add
>                     // here is the bug: status().call().getModified() does not return
files that have already been added to the index, it only returns files that have been modified
but not added to the index
>                     getLogger().warn( "there are no files to be added" );
>                     doCommit = false;
>                 }
>                 else {
>                     AddCommand add = git.add();
>                     for ( String changed : changeds ) {
>                         getLogger().debug( "add manualy: " + changed );
>                         add.addFilepattern( changed );
>                         doCommit = true;
>                     }
>                     add.call();
>                 }
>             }
>             List<ScmFile> checkedInFiles = Collections.emptyList();
>             if ( doCommit ) {
>                ....
>             }
>             ...
>     }
> A possible fix would be:
> if (!fileSet.getFileList().isEmpty()) {
>      doCommit = JGitUtils.addAllFiles(git, fileSet).size() > 0;
> } else {
>      // Bugfix: Files that have been added in advance by
>      // the user will not be committed if nothing else has changed.
>      // add all tracked files which are modified manually
>      Set<String> changeds = git.status().call().getModified();
>      if (!changeds.isEmpty()) {
>         AddCommand add = git.add();
>         for (String changed : changeds) {
>            getLogger().debug("add manually: " + changed);
>            add.addFilepattern(changed);
>            doCommit = true;
>         }
>        add.call();
>     }
>     Status status = git.status().call();
>     doCommit = !status.getUncommittedChanges().isEmpty();
>     if (!doCommit) {
>       getLogger().warn("there are no files to commit");
>     }
>  }
>  List<ScmFile> checkedInFiles = Collections.emptyList();
>  if (doCommit) {
>    ...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message