Merge lp:~cjwatson/launchpad-buildd/ttb-git into lp:launchpad-buildd

Proposed by Colin Watson on 2018-03-14
Status: Needs review
Proposed branch: lp:~cjwatson/launchpad-buildd/ttb-git
Merge into: lp:launchpad-buildd
Prerequisite: lp:~cjwatson/launchpad-buildd/refactor-vcs
Diff against target: 532 lines (+246/-152)
5 files modified
debian/changelog (+2/-0)
lpbuildd/target/generate_translation_templates.py (+25/-40)
lpbuildd/target/tests/test_generate_translation_templates.py (+202/-107)
lpbuildd/tests/test_translationtemplatesbuildmanager.py (+1/-1)
lpbuildd/translationtemplates.py (+16/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/ttb-git
Reviewer Review Type Date Requested Status
Launchpad code reviewers 2018-03-14 Pending
Review via email: mp+341389@code.launchpad.net

Commit message

Convert translation templates builds to the new VCS mixin, thereby adding git support.

Description of the change

There'll be a fair bit of work needed on the Launchpad side before this is useful, but we might as well get started here.

To post a comment you must log in.

Unmerged revisions

329. By Colin Watson on 2018-03-14

Convert translation templates builds to the new VCS mixin, thereby adding git support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2018-03-14 14:15:15 +0000
+++ debian/changelog 2018-03-14 14:15:15 +0000
@@ -7,6 +7,8 @@
7 * Allow optionally installing snapcraft as a snap (LP: #1737994).7 * Allow optionally installing snapcraft as a snap (LP: #1737994).
8 * Refactor VCS operations from lpbuildd.target.build_snap out to a module8 * Refactor VCS operations from lpbuildd.target.build_snap out to a module
9 that can be used by other targets.9 that can be used by other targets.
10 * Convert translation templates builds to the new VCS mixin, thereby
11 adding git support.
1012
11 -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Feb 2018 16:14:46 +000013 -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Feb 2018 16:14:46 +0000
1214
1315
=== modified file 'lpbuildd/target/generate_translation_templates.py'
--- lpbuildd/target/generate_translation_templates.py 2017-11-10 22:13:03 +0000
+++ lpbuildd/target/generate_translation_templates.py 2018-03-14 14:15:15 +0000
@@ -10,6 +10,7 @@
1010
11from lpbuildd.pottery import intltool11from lpbuildd.pottery import intltool
12from lpbuildd.target.operation import Operation12from lpbuildd.target.operation import Operation
13from lpbuildd.target.vcs import VCSOperationMixin
1314
1415
15logger = logging.getLogger(__name__)16logger = logging.getLogger(__name__)
@@ -19,7 +20,7 @@
19RETCODE_FAILURE_BUILD = 20120RETCODE_FAILURE_BUILD = 201
2021
2122
22class GenerateTranslationTemplates(Operation):23class GenerateTranslationTemplates(VCSOperationMixin, Operation):
23 """Script to generate translation templates from a branch."""24 """Script to generate translation templates from a branch."""
2425
25 description = "Generate templates for a branch."26 description = "Generate templates for a branch."
@@ -28,42 +29,24 @@
28 def add_arguments(cls, parser):29 def add_arguments(cls, parser):
29 super(GenerateTranslationTemplates, cls).add_arguments(parser)30 super(GenerateTranslationTemplates, cls).add_arguments(parser)
30 parser.add_argument(31 parser.add_argument(
31 "branch_spec", help=(
32 "A branch URL or the path of a local branch. URLs are "
33 "recognised by the occurrence of ':'. In the case of a URL, "
34 "this will make up a path for the branch and check out the "
35 "branch to there."))
36 parser.add_argument(
37 "result_name",32 "result_name",
38 help="The name of the result tarball. Should end in '.tar.gz'.")33 help="the name of the result tarball; should end in '.tar.gz'")
3934
40 def __init__(self, args, parser):35 def __init__(self, args, parser):
41 super(GenerateTranslationTemplates, self).__init__(args, parser)36 super(GenerateTranslationTemplates, self).__init__(args, parser)
42 self.work_dir = os.environ["HOME"]37 self.work_dir = os.environ["HOME"]
4338 self.branch_dir = os.path.join(self.work_dir, "source-tree")
44 def _getBranch(self):39
45 """Set `self.branch_dir`, and check out branch if needed."""40 def install(self):
46 if ':' in self.args.branch_spec:41 logger.info("Installing dependencies...")
47 # This is a branch URL. Check out the branch.42 deps = ["intltool"]
48 self.branch_dir = os.path.join(self.work_dir, 'source-tree')43 deps.extend(self.vcs_deps)
49 logger.info("Getting remote branch %s..." % self.args.branch_spec)44 self.backend.run(["apt-get", "-y", "install"] + deps)
50 self._checkout(self.args.branch_spec)45
51 else:46 def fetch(self, quiet=False):
52 # This is a local filesystem path. Use the branch in-place.47 logger.info("Fetching %s...", self.vcs_description)
53 logger.info("Using local branch %s..." % self.args.branch_spec)48 self.vcs_fetch(
54 self.branch_dir = self.args.branch_spec49 os.path.basename(self.branch_dir), cwd=self.work_dir, quiet=quiet)
55
56 def _checkout(self, branch_url):
57 """Check out a source branch to generate from.
58
59 The branch is checked out to the location specified by
60 `self.branch_dir`.
61 """
62 logger.info(
63 "Exporting branch %s to %s..." % (branch_url, self.branch_dir))
64 self.backend.run(
65 ["bzr", "export", "-q", "-d", branch_url, self.branch_dir])
66 logger.info("Exporting branch done.")
6750
68 def _makeTarball(self, files):51 def _makeTarball(self, files):
69 """Put the given files into a tarball in the working directory."""52 """Put the given files into a tarball in the working directory."""
@@ -78,21 +61,23 @@
78 self.backend.run(cmd)61 self.backend.run(cmd)
79 logger.info("Tarball generated.")62 logger.info("Tarball generated.")
8063
64 def generate(self):
65 logger.info("Generating templates...")
66 pots = intltool.generate_pots(self.backend, self.branch_dir)
67 logger.info("Generated %d templates." % len(pots))
68 if len(pots) > 0:
69 self._makeTarball(pots)
70
81 def run(self):71 def run(self):
82 """Do It. Generate templates."""72 """Do It. Generate templates."""
83 try:73 try:
84 self.backend.run(["apt-get", "-y", "install", "bzr", "intltool"])74 self.install()
85 except Exception:75 except Exception:
86 logger.exception("Install failed")76 logger.exception("Install failed")
87 return RETCODE_FAILURE_INSTALL77 return RETCODE_FAILURE_INSTALL
88 try:78 try:
89 logger.info(79 self.fetch()
90 "Generating templates for %s." % self.args.branch_spec)80 self.generate()
91 self._getBranch()
92 pots = intltool.generate_pots(self.backend, self.branch_dir)
93 logger.info("Generated %d templates." % len(pots))
94 if len(pots) > 0:
95 self._makeTarball(pots)
96 except Exception:81 except Exception:
97 logger.exception("Build failed")82 logger.exception("Build failed")
98 return RETCODE_FAILURE_BUILD83 return RETCODE_FAILURE_BUILD
9984
=== modified file 'lpbuildd/target/tests/test_generate_translation_templates.py'
--- lpbuildd/target/tests/test_generate_translation_templates.py 2017-10-27 08:08:49 +0000
+++ lpbuildd/target/tests/test_generate_translation_templates.py 2018-03-14 14:15:15 +0000
@@ -15,23 +15,37 @@
15from testtools import TestCase15from testtools import TestCase
16from testtools.matchers import (16from testtools.matchers import (
17 ContainsDict,17 ContainsDict,
18 EndsWith,
19 Equals,18 Equals,
19 Is,
20 MatchesDict,
20 MatchesListwise,21 MatchesListwise,
21 MatchesSetwise,22 MatchesSetwise,
22 )23 )
2324
24from lpbuildd.target.cli import parse_args25from lpbuildd.target.cli import parse_args
25from lpbuildd.tests.fakeslave import FakeMethod26
2627
2728class RanCommand(MatchesListwise):
28class MatchesCall(MatchesListwise):29
2930 def __init__(self, args, get_output=None, echo=None, cwd=None, **env):
30 def __init__(self, *args, **kwargs):31 kwargs_matcher = {}
31 super(MatchesCall, self).__init__([32 if get_output is not None:
32 Equals(args),33 kwargs_matcher["get_output"] = Is(get_output)
33 ContainsDict(34 if echo is not None:
34 {name: Equals(value) for name, value in kwargs.items()})])35 kwargs_matcher["echo"] = Is(echo)
36 if cwd:
37 kwargs_matcher["cwd"] = Equals(cwd)
38 if env:
39 kwargs_matcher["env"] = MatchesDict(
40 {key: Equals(value) for key, value in env.items()})
41 super(RanCommand, self).__init__(
42 [Equals((args,)), ContainsDict(kwargs_matcher)])
43
44
45class RanAptGet(RanCommand):
46
47 def __init__(self, *args):
48 super(RanAptGet, self).__init__(["apt-get", "-y"] + list(args))
3549
3650
37class TestGenerateTranslationTemplates(TestCase):51class TestGenerateTranslationTemplates(TestCase):
@@ -45,82 +59,125 @@
45 self.useFixture(EnvironmentVariable("HOME", self.home_dir))59 self.useFixture(EnvironmentVariable("HOME", self.home_dir))
46 self.logger = self.useFixture(FakeLogger())60 self.logger = self.useFixture(FakeLogger())
4761
48 def test_getBranch_url(self):62 def make_branch_contents(self, content_map):
49 # If passed a branch URL, the template generation script will63 """Create a directory with the contents of a working branch.
50 # check out that branch into a directory called "source-tree."64
51 args = [65 :param content_map: A dict mapping file names to file contents.
52 "generate-translation-templates",66 Each of these files with their contents will be written to the
53 "--backend=fake", "--series=xenial", "--arch=amd64", "1",67 branch. Currently only supports writing files at the root
54 "lp://~my/translation/branch", self.result_name,68 directory of the branch.
55 ]
56 generator = parse_args(args=args).operation
57 generator._checkout = FakeMethod()
58 generator._getBranch()
59
60 self.assertEqual(1, generator._checkout.call_count)
61 self.assertThat(generator.branch_dir, EndsWith("source-tree"))
62
63 def test_getBranch_dir(self):
64 # If passed a branch directory, the template generation script
65 # works directly in that directory.
66 branch_dir = "/home/me/branch"
67 args = [
68 "generate-translation-templates",
69 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
70 branch_dir, self.result_name,
71 ]
72 generator = parse_args(args=args).operation
73 generator._checkout = FakeMethod()
74 generator._getBranch()
75
76 self.assertEqual(0, generator._checkout.call_count)
77 self.assertEqual(branch_dir, generator.branch_dir)
78
79 def _createBranch(self, content_map=None):
80 """Create a working branch.
81
82 :param content_map: optional dict mapping file names to file
83 contents. Each of these files with their contents will be
84 written to the branch. Currently only supports writing files at
85 the root directory of the branch.
86
87 :return: the URL of a fresh bzr branch.
88 """69 """
89 branch_path = self.useFixture(TempDir()).path70 branch_path = self.useFixture(TempDir()).path
90 branch_url = 'file://' + branch_path71 for name, contents in content_map.items():
91 subprocess.check_call(['bzr', 'init', '-q'], cwd=branch_path)72 with open(os.path.join(branch_path, name), 'wb') as f:
9273 f.write(contents)
93 if content_map is not None:74 return branch_path
94 for name, contents in content_map.items():75
95 with open(os.path.join(branch_path, name), 'wb') as f:76 def make_bzr_branch(self, branch_path):
96 f.write(contents)77 """Make a bzr branch from an existing directory."""
78 bzr_home = self.useFixture(TempDir()).path
79 self.useFixture(EnvironmentVariable("BZR_HOME", bzr_home))
80 self.useFixture(EnvironmentVariable("BZR_EMAIL"))
81 self.useFixture(EnvironmentVariable("EMAIL"))
82
83 subprocess.check_call(["bzr", "init", "-q"], cwd=branch_path)
84 subprocess.check_call(["bzr", "add", "-q"], cwd=branch_path)
85 committer_id = "Committer <committer@example.com>"
86 with EnvironmentVariable("BZR_EMAIL", committer_id):
97 subprocess.check_call(87 subprocess.check_call(
98 ['bzr', 'add', '-q'] + list(content_map), cwd=branch_path)88 ["bzr", "commit", "-q", "-m", "Populating branch."],
99 committer_id = 'Committer <committer@example.com>'89 cwd=branch_path)
100 with EnvironmentVariable('BZR_EMAIL', committer_id):90
101 subprocess.check_call(91 def make_git_branch(self, branch_path):
102 ['bzr', 'commit', '-q', '-m', 'Populating branch.'],92 subprocess.check_call(["git", "init", "-q"], cwd=branch_path)
103 cwd=branch_path)93 subprocess.check_call(
10494 ["git", "config", "user.name", "Committer"], cwd=branch_path)
105 return branch_url95 subprocess.check_call(
10696 ["git", "config", "user.email", "committer@example.com"],
107 def test_getBranch_bzr(self):97 cwd=branch_path)
108 # _getBranch can retrieve branch contents from a branch URL.98 subprocess.check_call(["git", "add", "."], cwd=branch_path)
109 bzr_home = self.useFixture(TempDir()).path99 subprocess.check_call(
110 self.useFixture(EnvironmentVariable('BZR_HOME', bzr_home))100 ["git", "commit", "-q", "--allow-empty",
111 self.useFixture(EnvironmentVariable('BZR_EMAIL'))101 "-m", "Populating branch"],
112 self.useFixture(EnvironmentVariable('EMAIL'))102 cwd=branch_path)
113103
114 marker_text = "Ceci n'est pas cet branch."104 def test_install_bzr(self):
115 branch_url = self._createBranch({'marker.txt': marker_text})105 args = [
116106 "generate-translation-templates",
117 args = [107 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
118 "generate-translation-templates",108 "--branch", "lp:foo", self.result_name,
119 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",109 ]
120 branch_url, self.result_name,110 generator = parse_args(args=args).operation
121 ]111 generator.install()
122 generator = parse_args(args=args).operation112 self.assertThat(generator.backend.run.calls, MatchesListwise([
123 generator._getBranch()113 RanAptGet("install", "intltool", "bzr"),
114 ]))
115
116 def test_install_git(self):
117 args = [
118 "generate-translation-templates",
119 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
120 "--git-repository", "lp:foo", self.result_name,
121 ]
122 generator = parse_args(args=args).operation
123 generator.install()
124 self.assertThat(generator.backend.run.calls, MatchesListwise([
125 RanAptGet("install", "intltool", "git"),
126 ]))
127
128 def test_fetch_bzr(self):
129 # fetch can retrieve branch contents from a Bazaar branch.
130 marker_text = "Ceci n'est pas cet branch."
131 branch_path = self.make_branch_contents({'marker.txt': marker_text})
132 self.make_bzr_branch(branch_path)
133
134 args = [
135 "generate-translation-templates",
136 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",
137 "--branch", branch_path, self.result_name,
138 ]
139 generator = parse_args(args=args).operation
140 generator.fetch(quiet=True)
141
142 marker_path = os.path.join(generator.branch_dir, 'marker.txt')
143 with open(marker_path) as marker_file:
144 self.assertEqual(marker_text, marker_file.read())
145
146 def test_fetch_git(self):
147 # fetch can retrieve branch contents from a Git repository.
148 marker_text = "Ceci n'est pas cet branch."
149 branch_path = self.make_branch_contents({'marker.txt': marker_text})
150 self.make_git_branch(branch_path)
151
152 args = [
153 "generate-translation-templates",
154 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",
155 "--git-repository", branch_path, self.result_name,
156 ]
157 generator = parse_args(args=args).operation
158 generator.fetch(quiet=True)
159
160 marker_path = os.path.join(generator.branch_dir, 'marker.txt')
161 with open(marker_path) as marker_file:
162 self.assertEqual(marker_text, marker_file.read())
163
164 def test_fetch_git_with_path(self):
165 # fetch can retrieve branch contents from a Git repository and
166 # branch name.
167 marker_text = "Ceci n'est pas cet branch."
168 branch_path = self.make_branch_contents({'marker.txt': marker_text})
169 self.make_git_branch(branch_path)
170 subprocess.call(
171 ["git", "branch", "-m", "master", "next"], cwd=branch_path)
172
173 args = [
174 "generate-translation-templates",
175 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",
176 "--git-repository", branch_path, "--git-path", "next",
177 self.result_name,
178 ]
179 generator = parse_args(args=args).operation
180 generator.fetch(quiet=True)
124181
125 marker_path = os.path.join(generator.branch_dir, 'marker.txt')182 marker_path = os.path.join(generator.branch_dir, 'marker.txt')
126 with open(marker_path) as marker_file:183 with open(marker_path) as marker_file:
@@ -136,22 +193,23 @@
136 potnames = [193 potnames = [
137 member.name194 member.name
138 for member in tar.getmembers() if not member.isdir()]195 for member in tar.getmembers() if not member.isdir()]
196 self.make_bzr_branch(branchdir)
139197
140 args = [198 args = [
141 "generate-translation-templates",199 "generate-translation-templates",
142 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",200 "--backend=uncontained", "--series=xenial", "--arch=amd64", "1",
143 branchdir, self.result_name,201 "--branch", branchdir, self.result_name,
144 ]202 ]
145 generator = parse_args(args=args).operation203 generator = parse_args(args=args).operation
146 generator._getBranch()204 generator.fetch(quiet=True)
147 generator._makeTarball(potnames)205 generator._makeTarball(potnames)
148 result_path = os.path.join(self.home_dir, self.result_name)206 result_path = os.path.join(self.home_dir, self.result_name)
149 with tarfile.open(result_path, 'r|*') as tar:207 with tarfile.open(result_path, 'r|*') as tar:
150 tarnames = tar.getnames()208 tarnames = tar.getnames()
151 self.assertThat(tarnames, MatchesSetwise(*(map(Equals, potnames))))209 self.assertThat(tarnames, MatchesSetwise(*(map(Equals, potnames))))
152210
153 def test_run(self):211 def test_run_bzr(self):
154 # Install dependencies and generate a templates tarball.212 # Install dependencies and generate a templates tarball from Bazaar.
155 branch_url = "lp:~my/branch"213 branch_url = "lp:~my/branch"
156 branch_dir = os.path.join(self.home_dir, "source-tree")214 branch_dir = os.path.join(self.home_dir, "source-tree")
157 po_dir = os.path.join(branch_dir, "po")215 po_dir = os.path.join(branch_dir, "po")
@@ -160,24 +218,61 @@
160 args = [218 args = [
161 "generate-translation-templates",219 "generate-translation-templates",
162 "--backend=fake", "--series=xenial", "--arch=amd64", "1",220 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
163 branch_url, self.result_name,221 "--branch", branch_url, self.result_name,
164 ]222 ]
165 generator = parse_args(args=args).operation223 generator = parse_args(args=args).operation
166 generator.backend.add_file(os.path.join(po_dir, "POTFILES.in"), "")224 generator.backend.add_file(os.path.join(po_dir, "POTFILES.in"), "")
167 generator.backend.add_file(225 generator.backend.add_file(
168 os.path.join(po_dir, "Makevars"), "DOMAIN = test\n")226 os.path.join(po_dir, "Makevars"), "DOMAIN = test\n")
169 generator.run()227 generator.run()
170 self.assertThat(generator.backend.run.calls, MatchesListwise([228 self.assertThat(generator.backend.run.calls, MatchesListwise([
171 MatchesCall(["apt-get", "-y", "install", "bzr", "intltool"]),229 RanAptGet("install", "intltool", "bzr"),
172 MatchesCall(230 RanCommand(
173 ["bzr", "export", "-q", "-d", "lp:~my/branch", branch_dir]),231 ["bzr", "branch", "lp:~my/branch", "source-tree"],
174 MatchesCall(232 cwd=self.home_dir, LANG="C.UTF-8", SHELL="/bin/sh"),
175 ["rm", "-f",233 RanCommand(
176 os.path.join(po_dir, "missing"),234 ["rm", "-f",
177 os.path.join(po_dir, "notexist")]),235 os.path.join(po_dir, "missing"),
178 MatchesCall(["/usr/bin/intltool-update", "-m"], cwd=po_dir),236 os.path.join(po_dir, "notexist")]),
179 MatchesCall(237 RanCommand(["/usr/bin/intltool-update", "-m"], cwd=po_dir),
180 ["/usr/bin/intltool-update", "-p", "-g", "test"], cwd=po_dir),238 RanCommand(
181 MatchesCall(239 ["/usr/bin/intltool-update", "-p", "-g", "test"], cwd=po_dir),
240 RanCommand(
241 ["tar", "-C", branch_dir, "-czf", result_path, "po/test.pot"]),
242 ]))
243
244 def test_run_git(self):
245 # Install dependencies and generate a templates tarball from Git.
246 repository_url = "lp:~my/repository"
247 branch_dir = os.path.join(self.home_dir, "source-tree")
248 po_dir = os.path.join(branch_dir, "po")
249 result_path = os.path.join(self.home_dir, self.result_name)
250
251 args = [
252 "generate-translation-templates",
253 "--backend=fake", "--series=xenial", "--arch=amd64", "1",
254 "--git-repository", repository_url, self.result_name,
255 ]
256 generator = parse_args(args=args).operation
257 generator.backend.add_file(os.path.join(po_dir, "POTFILES.in"), "")
258 generator.backend.add_file(
259 os.path.join(po_dir, "Makevars"), "DOMAIN = test\n")
260 generator.run()
261 self.assertThat(generator.backend.run.calls, MatchesListwise([
262 RanAptGet("install", "intltool", "git"),
263 RanCommand(
264 ["git", "clone", "lp:~my/repository", "source-tree"],
265 cwd=self.home_dir, LANG="C.UTF-8", SHELL="/bin/sh"),
266 RanCommand(
267 ["git", "submodule", "update", "--init", "--recursive"],
268 cwd=branch_dir, LANG="C.UTF-8", SHELL="/bin/sh"),
269 RanCommand(
270 ["rm", "-f",
271 os.path.join(po_dir, "missing"),
272 os.path.join(po_dir, "notexist")]),
273 RanCommand(["/usr/bin/intltool-update", "-m"], cwd=po_dir),
274 RanCommand(
275 ["/usr/bin/intltool-update", "-p", "-g", "test"], cwd=po_dir),
276 RanCommand(
182 ["tar", "-C", branch_dir, "-czf", result_path, "po/test.pot"]),277 ["tar", "-C", branch_dir, "-czf", result_path, "po/test.pot"]),
183 ]))278 ]))
184279
=== modified file 'lpbuildd/tests/test_translationtemplatesbuildmanager.py'
--- lpbuildd/tests/test_translationtemplatesbuildmanager.py 2017-09-08 15:57:18 +0000
+++ lpbuildd/tests/test_translationtemplatesbuildmanager.py 2018-03-14 14:15:15 +0000
@@ -82,7 +82,7 @@
82 'generate-translation-templates',82 'generate-translation-templates',
83 '--backend=chroot', '--series=xenial', '--arch=i386',83 '--backend=chroot', '--series=xenial', '--arch=i386',
84 self.buildid,84 self.buildid,
85 url, 'resultarchive',85 '--branch', url, 'resultarchive',
86 ]86 ]
87 self.assertEqual(expected_command, self.buildmanager.commands[-1])87 self.assertEqual(expected_command, self.buildmanager.commands[-1])
88 self.assertEqual(88 self.assertEqual(
8989
=== modified file 'lpbuildd/translationtemplates.py'
--- lpbuildd/translationtemplates.py 2017-09-08 15:57:18 +0000
+++ lpbuildd/translationtemplates.py 2018-03-14 14:15:15 +0000
@@ -36,16 +36,28 @@
3636
37 def initiate(self, files, chroot, extra_args):37 def initiate(self, files, chroot, extra_args):
38 """See `BuildManager`."""38 """See `BuildManager`."""
39 self._branch_url = extra_args['branch_url']39 self.branch = extra_args.get('branch')
40 # XXX cjwatson 2017-11-10: Backward-compatibility; remove once the
41 # manager passes branch instead.
42 if self.branch is None:
43 self.branch = extra_args['branch_url']
44 self.git_repository = extra_args.get("git_repository")
45 self.git_path = extra_args.get("git_path")
4046
41 super(TranslationTemplatesBuildManager, self).initiate(47 super(TranslationTemplatesBuildManager, self).initiate(
42 files, chroot, extra_args)48 files, chroot, extra_args)
4349
44 def doGenerate(self):50 def doGenerate(self):
45 """Generate templates."""51 """Generate templates."""
46 self.runTargetSubProcess(52 args = []
47 "generate-translation-templates",53 if self.branch is not None:
48 self._branch_url, self._resultname)54 args.extend(["--branch", self.branch])
55 if self.git_repository is not None:
56 args.extend(["--git-repository", self.git_repository])
57 if self.git_path is not None:
58 args.extend(["--git-path", self.git_path])
59 args.append(self._resultname)
60 self.runTargetSubProcess("generate-translation-templates", *args)
4961
50 # Satisfy DebianPackageManager's needs without having a misleading62 # Satisfy DebianPackageManager's needs without having a misleading
51 # method name here.63 # method name here.

Subscribers

People subscribed via source and target branches

to all changes: