def test_check_ignored(self): with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f: f.write("foo") with open(os.path.join(self.repo.path, 'foo'), 'w') as f: f.write("BAR") with open(os.path.join(self.repo.path, 'bar'), 'w') as f: f.write("BAR") self.assertEqual(['foo'], list(porcelain.check_ignore(self.repo, ['foo']))) self.assertEqual([], list(porcelain.check_ignore(self.repo, ['bar'])))
def test_check_added(self): with open(os.path.join(self.repo.path, 'foo'), 'w') as f: f.write("BAR") self.repo.stage(['foo']) with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f: f.write("foo\n") self.assertEqual([], list(porcelain.check_ignore(self.repo, ['foo']))) self.assertEqual(['foo'], list( porcelain.check_ignore(self.repo, ['foo'], no_index=True)))
def test_check_added(self): with open(os.path.join(self.repo.path, 'foo'), 'w') as f: f.write("BAR") self.repo.stage(['foo']) with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f: f.write("foo\n") self.assertEqual( [], list(porcelain.check_ignore(self.repo, ['foo']))) self.assertEqual( ['foo'], list(porcelain.check_ignore(self.repo, ['foo'], no_index=True)))
def test_check_ignored(self): with open(os.path.join(self.repo.path, '.gitignore'), 'w') as f: f.write("foo") with open(os.path.join(self.repo.path, 'foo'), 'w') as f: f.write("BAR") with open(os.path.join(self.repo.path, 'bar'), 'w') as f: f.write("BAR") self.assertEqual( ['foo'], list(porcelain.check_ignore(self.repo, ['foo']))) self.assertEqual([], list(porcelain.check_ignore(self.repo, ['bar'])))
def run(self, args): parser = optparse.OptionParser() options, args = parser.parse_args(args) ret = 1 for path in porcelain.check_ignore('.', args): print(path) ret = 0 return ret