

def test_commit(self):
    "\n        Test git.commit two ways:\n            1) First using git.add, then git.commit\n            2) Using git.commit with the 'filename' argument to skip staging\n        "
    filename = 'foo'
    commit_re_prefix = '^\\[master [0-9a-f]+\\] '
    with open(os.path.join(self.repo, filename), 'a') as fp_:
        fp_.write('Added a line\n')
    self.run_function('git.add', [self.repo, filename])
    commit_msg = ('Add a line to ' + filename)
    ret = self.run_function('git.commit', [self.repo, commit_msg])
    self.assertTrue(bool(re.search((commit_re_prefix + commit_msg), ret)))
    with open(os.path.join(self.repo, filename), 'a') as fp_:
        fp_.write('Added another line\n')
    commit_msg = ('Add another line to ' + filename)
    ret = self.run_function('git.commit', [self.repo, commit_msg], filename=filename)
    self.assertTrue(bool(re.search((commit_re_prefix + commit_msg), ret)))

dataset/ETHPy150Open saltstack/salt/tests/integration/modules/git.py GitModuleTest.test_commit/original