doorstop icon indicating copy to clipboard operation
doorstop copied to clipboard

Git VCS class parses gitignore files differently from git

Open asimon-1 opened this issue 4 years ago • 2 comments

Steps to reproduce the issue:

  • Initialize a Doorstop project with git as the version control provider
  • Create the file testfile1.txt in the project root
  • Create the file testfile2.txt in a .dir directory within the project root
  • Add an item with the ref field pointing to testfile1.txt
  • Add an item with the ref field pointing to testfile2.txt
  • Put the following lines in the .gitignore file to ignore all files within any directory that begins with a period
.*/
!.gitignore
  • Git should ignore testfile2.txt but not testfile1.txt
  • Run the Doorstop validation routine, and observe that the external reference finder for both items fails, when only testfile2.txt is in an ignored directory

Thoughts for the cause of the issue

The VCS class for git utilizes the .gitignore file to determine which files to ignore. The BaseWorkingCopy superclass strips leading and trailing slashes and uses relative paths for all patterns, which can cause differences in interpretation between Doorstop's file discovery and git's. The gitignore documentation is available here: https://git-scm.com/docs/gitignore

asimon-1 avatar Sep 09 '20 14:09 asimon-1

Note that this particular example is also entangled with the if branch that excludes the common hidden filename convention.

    def paths(self):
        """Yield non-ignored paths in the working copy."""
   ...
                    # Skip hidden paths
                    if os.path.sep + '.' in os.path.sep + relpath:
                        continue
    ...

asimon-1 avatar Sep 09 '20 16:09 asimon-1

It may be the case that Doorstop matches the "." portion of this rule matches to the project root instead of the period character.

asimon-1 avatar Sep 09 '20 16:09 asimon-1