Esempio n. 1
0
 def test_handleignore_global_extensions(self):
     with testhelper.mkchdir("aFolder") as folder:
         # create test repo
         configuration.config = Builder().setworkdirectory(
             folder).setgitreponame("test.git").setignorefileextensions(
                 ".zip; .jar").build()
         ignore = ".gitignore"
         Initializer().createrepo()
         # simulate addition of .zip and .jar files
         zip = "test.zip"
         with open(zip, 'w') as testzip:
             testzip.write("test zip content")
         jar = "test.jar"
         with open(jar, 'w') as testjar:
             testjar.write("test jar content")
         # do the filtering
         Commiter.handleignore()
         # check output of .gitignore
         with open(ignore, 'r') as gitIgnore:
             lines = gitIgnore.readlines()
             self.assertEqual(2, len(lines))
             lines.sort()
             # the ignore should not be recursive:
             self.assertEqual('/' + jar, lines[0].strip())
             self.assertEqual('/' + zip, lines[1].strip())
Esempio n. 2
0
 def test_handleignore_local_jazzignore_expect_delete_gitignore(self):
     with testhelper.mkchdir("aFolder") as folder:
         # create a repository with a .jazzignore and .gitignore file
         configuration.config = Builder().setworkdirectory(folder).setgitreponame("test.git").build()
         Initializer().createrepo()
         subfolder = "aSubFolder"
         os.mkdir(subfolder)
         jazzignore = subfolder + os.sep + ".jazzignore"
         with open(jazzignore, 'w') as testjazzignore:
             testjazzignore.write("# my ignores\n")
             testjazzignore.write("core.ignore = {*.pyc}")
         Commiter.addandcommit(testhelper.createchangeentry(comment="Initial .jazzignore"))
         gitignore = subfolder + os.sep + ".gitignore"
         self.assertTrue(os.path.exists(gitignore))
         # now remove .jazzignore
         os.remove(jazzignore)
         Commiter.handleignore()
         self.assertFalse(os.path.exists(gitignore))
Esempio n. 3
0
 def test_handleignore_local_jazzignore_expect_empty_gitignore(self):
     with testhelper.mkchdir("aFolder") as folder:
         configuration.config = Builder().setworkdirectory(folder).setgitreponame("test.git").build()
         Initializer().createrepo()
         subfolder = "aSubFolder"
         os.mkdir(subfolder)
         gitignore = subfolder + os.sep + ".gitignore"
         with open(gitignore, 'w') as localgitignore:
             localgitignore.write('\n')
             localgitignore.write("/*.pyc")
         jazzignore = subfolder + os.sep + ".jazzignore"
         with open(jazzignore, 'w') as testjazzignore:
             testjazzignore.write("# my ignores are empty\n")
         Commiter.handleignore()
         self.assertTrue(os.path.exists(gitignore))
         gitignorelines = []
         with open(gitignore, 'r') as localgitignore:
             gitignorelines = localgitignore.readlines()
         self.assertEqual(0, len(gitignorelines))
Esempio n. 4
0
 def test_handleignore_local_jazzignore_expect_new_gitignore(self):
     with testhelper.mkchdir("aFolder") as folder:
         configuration.config = Builder().setworkdirectory(folder).setgitreponame("test.git").build()
         Initializer().createrepo()
         subfolder = "aSubFolder"
         os.mkdir(subfolder)
         jazzignore = subfolder + os.sep + ".jazzignore"
         with open(jazzignore, 'w') as testjazzignore:
             testjazzignore.write("# my ignores\n")
             testjazzignore.write("core.ignore = {*.pyc}")
         expectedlines = ["\n","/*.pyc\n"]
         gitignore = subfolder + os.sep + ".gitignore"
         self.assertFalse(os.path.exists(gitignore))
         Commiter.handleignore()
         self.assertTrue(os.path.exists(gitignore))
         gitignorelines = []
         with open(gitignore, 'r') as localgitignore:
             gitignorelines = localgitignore.readlines()
         self.assertEqual(expectedlines, gitignorelines)
Esempio n. 5
0
 def test_handleignore_global_extensions(self):
     with testhelper.mkchdir("aFolder") as folder:
         # create test repo
         configuration.config = Builder().setworkdirectory(folder).setgitreponame("test.git").setignorefileextensions(".zip; .jar").build()
         ignore = ".gitignore"
         Initializer().createrepo()
         # simulate addition of .zip and .jar files
         zip = "test.zip"
         with open(zip, 'w') as testzip:
             testzip.write("test zip content")
         jar = "test.jar"
         with open(jar, 'w') as testjar:
             testjar.write("test jar content")
         # do the filtering
         Commiter.handleignore()
         # check output of .gitignore
         with open(ignore, 'r') as gitIgnore:
             lines = gitIgnore.readlines()
             self.assertEqual(2, len(lines))
             lines.sort()
             # the ignore should not be recursive:
             self.assertEqual('/' + jar, lines[0].strip())
             self.assertEqual('/' + zip, lines[1].strip())