Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gitFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def createignore():
ignore.write(newline + "# directories" + newline)
for directory in config.ignoredirectories:
ignore.write('/' + directory + newline)
ignore.write(newline)
shell.execute("git add " + git_ignore)
shell.execute("git commit -m %s -q" % shell.quote("Add .gitignore"))

Expand Down Expand Up @@ -320,6 +321,8 @@ def match(repositoryfiles, extensions):
extlen = len(extension)
if len(repositoryfile) >= extlen:
if repositoryfile[-extlen:] == extension:
# escape a backslash with a backslash, and append a newline
repositoryfilestoignore.append(repositoryfile.replace('\\', '\\\\') + os.linesep)
# prepend a forward slash (for non recursive,)
# escape a backslash with a backslash
# append a newline
repositoryfilestoignore.append('/' + repositoryfile.replace('\\', '\\\\') + os.linesep)
return repositoryfilestoignore
6 changes: 4 additions & 2 deletions tests/test_gitFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_CreationOfGitIgnore_DoesntExist_ShouldGetCreated_WithDirectories(self):
expectedlines.append("# directories\n")
expectedlines.append("/projectX/dist\n")
expectedlines.append("/projectZ/out\n")
expectedlines.append("\n")
with open(gitignorepath, 'r') as gitignore:
lines = gitignore.readlines()
self.assertEqual(expectedlines, lines)
Expand Down Expand Up @@ -223,8 +224,9 @@ def test_handleignore_global_extensions(self):
lines = gitIgnore.readlines()
self.assertEqual(2, len(lines))
lines.sort()
self.assertEqual(jar, lines[0].strip())
self.assertEqual(zip, lines[1].strip())
# the ignore should not be recursive:
self.assertEqual('/' + jar, lines[0].strip())
self.assertEqual('/' + zip, lines[1].strip())

def test_handleignore_local_jazzignore_expect_new_gitignore(self):
with testhelper.mkchdir("aFolder") as folder:
Expand Down