Merge lp:~tsimonq2/ubuntu-archive-tools/add-git-support-to-branch-seeds into lp:ubuntu-archive-tools

Proposed by Simon Quigley
Status: Merged
Approved by: Steve Langasek
Approved revision: 1145
Merged at revision: 1143
Proposed branch: lp:~tsimonq2/ubuntu-archive-tools/add-git-support-to-branch-seeds
Merge into: lp:ubuntu-archive-tools
Diff against target: 86 lines (+45/-17)
1 file modified
branch-seeds (+45/-17)
To merge this branch: bzr merge lp:~tsimonq2/ubuntu-archive-tools/add-git-support-to-branch-seeds
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Review via email: mp+335687@code.launchpad.net

Description of the change

This has the same sort of purpose as https://code.launchpad.net/~tsimonq2/ubuntu-cdimage/add-git-support-to-germinate/+merge/335604 and that is to add support for Lubuntu's move to having our seed in a Git repository instead of one managed under Bazaar.

Adding Steve as a reviewer because he reviewed the other MP.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

Requesting a few changes, mostly stylistic.

review: Needs Fixing
1137. By Colin Watson

copy-build-scheduler: convert to argparse

1138. By Colin Watson

copy-build-scheduler: switch to Python 3

1139. By Colin Watson

copy-build-scheduler: skip inactive builders

1140. By Colin Watson

lputils.py: use argparse-style naming (no functional change)

1141. By Colin Watson

copy-package: convert to argparse

1142. By Colin Watson

manage-chroot: convert to argparse

Revision history for this message
Simon Quigley (tsimonq2) :
1143. By Simon Quigley

Add Git support to branch-seeds.

1144. By Simon Quigley

Refactor some changes after feedback from slangasek.

Revision history for this message
Steve Langasek (vorlon) wrote :

another round of minor changes

review: Needs Fixing
1145. By Simon Quigley

Reduce to if vcs, rest of that if/else isn't needed.

Revision history for this message
Simon Quigley (tsimonq2) wrote :

How's that, Steve?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'branch-seeds'
2--- branch-seeds 2012-08-01 09:47:07 +0000
3+++ branch-seeds 2018-01-08 22:05:31 +0000
4@@ -29,6 +29,20 @@
5 from urlparse import urlparse
6
7 from launchpadlib.launchpad import Launchpad
8+from enum import Enum
9+
10+class VCS(Enum):
11+ Git = 1
12+ Bazaar = 2
13+
14+ @staticmethod
15+ def detect_vcs(source):
16+ if os.path.exists(os.path.join(source, ".git")):
17+ return VCS.Git
18+ elif os.path.exists(os.path.join(source, ".bzr")):
19+ return VCS.Bazaar
20+ else:
21+ return None
22
23
24 def remote_branch(source):
25@@ -50,21 +64,28 @@
26 def branch(options, collection):
27 source = "%s.%s" % (collection, options.source_series)
28 dest = "%s.%s" % (collection, options.dest_series)
29- if os.path.exists(source):
30- subprocess.check_call(["bzr", "up", source])
31- remote_source = remote_branch(source)
32- remote_dest = os.path.join(os.path.dirname(remote_source), dest)
33- subprocess.check_call(["bzr", "branch", source, dest])
34- subprocess.check_call(["bzr", "push", "-d", dest, remote_dest])
35- subprocess.check_call(["bzr", "bind", ":push"], cwd=dest)
36-
37- lp_source = lp_branch(options, remote_source)
38- lp_source.lifecycle_status = "Mature"
39- lp_source.lp_save()
40-
41- lp_dest = lp_branch(options, remote_dest)
42- lp_dest.lifecycle_status = "Development"
43- lp_dest.lp_save()
44+ vcs = VCS.detect_vcs(source)
45+ if vcs:
46+ if vcs is VCS.Bazaar:
47+ subprocess.check_call(["bzr", "up", source])
48+ remote_source = remote_branch(source)
49+ remote_dest = os.path.join(os.path.dirname(remote_source), dest)
50+ subprocess.check_call(["bzr", "branch", source, dest])
51+ subprocess.check_call(["bzr", "push", "-d", dest, remote_dest])
52+ subprocess.check_call(["bzr", "bind", ":push"], cwd=dest)
53+
54+ lp_source = lp_branch(options, remote_source)
55+ lp_source.lifecycle_status = "Mature"
56+ lp_source.lp_save()
57+
58+ lp_dest = lp_branch(options, remote_dest)
59+ lp_dest.lifecycle_status = "Development"
60+ lp_dest.lp_save()
61+ elif vcs is VCS.Git:
62+ subprocess.check_call(["git", "fetch"], cwd=source)
63+ subprocess.check_call(["git", "reset", "--hard", "FETCH_HEAD"], cwd=source)
64+ os.rename(source, dest)
65+ subprocess.check_call(["git", "checkout", "-b", options.dest_series], cwd=dest)
66
67 re_include_source = re.compile(
68 r"^(include )(.*)\.%s" % options.source_series)
69@@ -89,8 +110,15 @@
70 os.rename(
71 os.path.join(dest, "STRUCTURE.new"),
72 os.path.join(dest, "STRUCTURE"))
73- subprocess.check_call(
74- ["bzr", "commit", "-m", "; ".join(message)], cwd=dest)
75+ if vcs is VCS.Bazaar:
76+ subprocess.check_call(
77+ ["bzr", "commit", "-m", "; ".join(message)], cwd=dest)
78+ elif vcs is VCS.Git:
79+ subprocess.check_call(["git", "add", "STRUCTURE"], cwd=dest)
80+ subprocess.check_call(
81+ ["git", "commit", "-m", "; ".join(message)], cwd=dest)
82+ subprocess.check_call(
83+ ["git", "push", "origin", options.dest_series], cwd=dest)
84
85
86 def main():

Subscribers

People subscribed via source and target branches