self._git_command("rm", args + paths)
+ def _commit(self, msg, args=[], author_info=None):
+ extra_env = author_info.get_author_env() if author_info else None
+ self._git_command("commit", args + ['-q', '-m', msg], extra_env=extra_env)
+
+
+ def commit(self, msg, author_info=None):
+ """
+ Commit currently staged files to the repository
+
+ @param msg: commit message
+ @type msg: string
+ @param author_info: authorship information
+ @type author_info: L{GitModifier}
+ """
+ self._commit(msg=msg, author_info=author_info)
+
+
+ def commit_all(self, msg, author_info=None):
+ """
+ Commit all changes to the repository
+ @param msg: commit message
+ @type msg: string
+ @param author_info: authorship information
+ @type author_info: L{GitModifier}
+ """
+ self._commit(msg=msg, args=['-a'], author_info=author_info)
+
+
def format_patches(self, start, end, output_dir):
"""
Output the commits between start and end as patches in output_dir
import tarfile
import tempfile
+import gbp.log
import gbp.git
import gbp.command_wrappers
def setup():
global repo, repodir, submodules, top, tmpdir
+ gbp.log.setup(False, True)
top = os.path.abspath(os.curdir)
tmpdir =os.path.join(top,'gbp_%s_repo' % __name__)
os.mkdir(tmpdir)
assert not repo.has_submodules()
-def _add_dummy_data(msg):
+def _add_dummy_data(repo, msg):
shutil.copy(".git/HEAD", testfile_name)
repo.add_files('.', force=True)
- gbp.command_wrappers.GitCommand("commit", ["-m%s" % msg, "-a"])()
+ repo.commit_all(msg)
def test_add_files():
"""Add some dummy data"""
- _add_dummy_data("initial commit")
+ _add_dummy_data(repo, "initial commit")
assert True
"""Add some dummy data"""
for submodule in submodules:
os.chdir(submodule.dir)
- _add_dummy_data("initial commit in submodule")
+ _add_dummy_data(submodule.repo, "initial commit in submodule")
os.chdir(repodir)
assert True
def test_add_submodule():
"""Add a submodule"""
repo.add_submodule(submodules[0].dir)
- gbp.command_wrappers.GitCommand("commit",
- ["-m 'Added submodule %s'" % submodules[0].dir,
- "-a"])()
+ repo.commit_all(msg='Added submodule %s' % submodules[0].dir)
def test_has_submodules():
"""Check for submodules"""
def test_add_whitespace_submodule():
"""Add a second submodule with name containing whitespace"""
repo.add_submodule(submodules[1].dir)
- gbp.command_wrappers.GitCommand("commit",
- ["-m 'Added submodule %s'" % submodules[0].dir,
- "-a"])()
+ repo.commit_all(msg='Added submodule %s' % submodules[0].dir)
def test_get_more_submodules():
"""Check for submodules list of (name, hash)"""