Add format string option to git cl archive

This option lets users specify a format of the archive tags. E.g.
  git cl archive -p 'archived/{issue}-{branch}'
makes tags in the format
  archived/1234-foo-feature

Change-Id: Icb74cc68781cda21a70c802bd640543e92ae97a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116723
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 1cf2880..721719f 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -2201,6 +2201,22 @@
 
     self.assertEqual(0, git_cl.main(['archive', '-f']))
 
+  def test_archive_with_format(self):
+    self.calls = [
+        ((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'], ),
+         'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
+        ((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'], ), ''),
+        ((['git', 'tag', 'archived/12-foo', 'foo'], ), ''),
+        ((['git', 'branch', '-D', 'foo'], ), ''),
+    ]
+
+    mock.patch('git_cl.get_cl_statuses',
+              lambda branches, fine_grained, max_processes:
+              [(MockChangelistWithBranchAndIssue('foo', 12), 'closed')]).start()
+
+    self.assertEqual(
+        0, git_cl.main(['archive', '-f', '-p', 'archived/{issue}-{branch}']))
+
   def test_cmd_issue_erase_existing(self):
     self.mockGit.config['branch.master.gerritissue'] = '123'
     self.mockGit.config['branch.master.gerritserver'] = (