porcelain.tag('.', args[0])
+def cmd_repack(args):
+ opts, args = getopt(args, "", [])
+ opts = dict(opts)
+ porcelain.repack('.')
+
+
def cmd_reset(args):
opts, args = getopt(args, "", ["hard", "soft", "mixed"])
opts = dict(opts)
"log": cmd_log,
"ls-remote": cmd_ls_remote,
"receive-pack": cmd_receive_pack,
+ "repack": cmd_repack,
"reset": cmd_reset,
"rev-list": cmd_rev_list,
"rm": cmd_rm,
def ls_remote(remote):
client, host_path = get_transport_and_path(remote)
return client.get_refs(encode_path(host_path))
+
+
+def repack(repo):
+ """Repack loose files in a repository.
+
+ Currently this only packs loose objects.
+
+ :param repo: Path to the repository
+ """
+ with open_repo_closing(repo) as r:
+ r.object_store.pack_loose_objects()
# Check the target repo for pushed changes
with closing(Repo(target_path)) as r:
self.assertTrue(self.repo[b'HEAD'].id in r)
+
+
+class RepackTests(PorcelainTestCase):
+
+ def test_empty(self):
+ porcelain.repack(self.repo)
+
+ def test_simple(self):
+ handle, fullpath = tempfile.mkstemp(dir=self.repo.path)
+ os.close(handle)
+ filename = os.path.basename(fullpath)
+ porcelain.add(repo=self.repo.path, paths=filename)
+ porcelain.repack(self.repo)