Merge lp:~cjwatson/launchpad/build-aux-snap into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18938
Proposed branch: lp:~cjwatson/launchpad/build-aux-snap
Merge into: lp:launchpad
Diff against target: 139 lines (+46/-10)
4 files modified
lib/lp/snappy/interfaces/snap.py (+13/-8)
lib/lp/snappy/model/snap.py (+1/-0)
lib/lp/snappy/templates/snap-new.pt (+3/-2)
lib/lp/snappy/tests/test_snap.py (+29/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/build-aux-snap
Reviewer Review Type Date Requested Status
William Grant (community) code Approve
Review via email: mp+366114@code.launchpad.net

Commit message

Add build-aux/snap/snapcraft.yaml to the list of possible snapcraft.yaml paths.

Description of the change

I don't really love this, but it's a passable compromise and will do for now. The ordering I chose is in sync with that used in snapcraft.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

I'm *really* not a fan of that ordering, but okay.

We might as well just generate all possible combinations of characters at this point and check them all.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/snappy/interfaces/snap.py'
2--- lib/lp/snappy/interfaces/snap.py 2019-03-29 16:22:20 +0000
3+++ lib/lp/snappy/interfaces/snap.py 2019-04-16 13:16:29 +0000
4@@ -661,7 +661,8 @@
5 required=False, readonly=False,
6 description=_(
7 "A Bazaar branch containing a snap/snapcraft.yaml, "
8- "snapcraft.yaml, or .snapcraft.yaml recipe at the top level.")))
9+ "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
10+ ".snapcraft.yaml recipe at the top level.")))
11
12 git_repository = exported(ReferenceChoice(
13 title=_("Git repository"),
14@@ -669,14 +670,15 @@
15 required=False, readonly=True,
16 description=_(
17 "A Git repository with a branch containing a snap/snapcraft.yaml, "
18- "snapcraft.yaml, or .snapcraft.yaml recipe at the top level.")))
19+ "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
20+ ".snapcraft.yaml recipe at the top level.")))
21
22 git_repository_url = exported(URIField(
23 title=_("Git repository URL"), required=False, readonly=True,
24 description=_(
25 "The URL of a Git repository with a branch containing a "
26- "snap/snapcraft.yaml, snapcraft.yaml, or .snapcraft.yaml recipe "
27- "at the top level."),
28+ "snap/snapcraft.yaml, build-aux/snap/snapcraft.yaml, "
29+ "snapcraft.yaml, or .snapcraft.yaml recipe at the top level."),
30 allowed_schemes=["git", "http", "https"],
31 allow_userinfo=True,
32 allow_port=True,
33@@ -688,7 +690,8 @@
34 title=_("Git branch path"), required=False, readonly=False,
35 description=_(
36 "The path of the Git branch containing a snap/snapcraft.yaml, "
37- "snapcraft.yaml, or .snapcraft.yaml recipe at the top level."))
38+ "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
39+ ".snapcraft.yaml recipe at the top level."))
40 _api_git_path = exported(
41 TextLine(
42 title=git_path.title, required=False, readonly=False,
43@@ -698,8 +701,9 @@
44 git_ref = exported(Reference(
45 IGitRef, title=_("Git branch"), required=False, readonly=False,
46 description=_(
47- "The Git branch containing a snap/snapcraft.yaml, snapcraft.yaml, "
48- "or .snapcraft.yaml recipe at the top level.")))
49+ "The Git branch containing a snap/snapcraft.yaml, "
50+ "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
51+ ".snapcraft.yaml recipe at the top level.")))
52
53 build_source_tarball = exported(Bool(
54 title=_("Build source tarball"),
55@@ -713,7 +717,8 @@
56 required=True, readonly=False,
57 description=_(
58 "Whether this snap package is built automatically when the branch "
59- "containing its snap/snapcraft.yaml, snapcraft.yaml, or "
60+ "containing its snap/snapcraft.yaml, "
61+ "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
62 ".snapcraft.yaml recipe changes.")))
63
64 auto_build_archive = exported(Reference(
65
66=== modified file 'lib/lp/snappy/model/snap.py'
67--- lib/lp/snappy/model/snap.py 2019-04-01 09:03:46 +0000
68+++ lib/lp/snappy/model/snap.py 2019-04-16 13:16:29 +0000
69@@ -1281,6 +1281,7 @@
70 try:
71 paths = (
72 "snap/snapcraft.yaml",
73+ "build-aux/snap/snapcraft.yaml",
74 "snapcraft.yaml",
75 ".snapcraft.yaml",
76 )
77
78=== modified file 'lib/lp/snappy/templates/snap-new.pt'
79--- lib/lp/snappy/templates/snap-new.pt 2018-04-30 16:48:47 +0000
80+++ lib/lp/snappy/templates/snap-new.pt 2019-04-16 13:16:29 +0000
81@@ -15,8 +15,9 @@
82 Core</a>. Launchpad can build snap packages using <a
83 href="https://developer.ubuntu.com/en/snappy/snapcraft/">snapcraft</a>,
84 from any Git or Bazaar branch on Launchpad that has a
85- <tt>snap/snapcraft.yaml</tt>, <tt>snapcraft.yaml</tt>, or
86- <tt>.snapcraft.yaml</tt> file at its top level.
87+ <tt>snap/snapcraft.yaml</tt>, <tt>build-aux/snap/snapcraft.yaml</tt>,
88+ <tt>snapcraft.yaml</tt>, or <tt>.snapcraft.yaml</tt> file at its top
89+ level.
90 </p>
91 </div>
92
93
94=== modified file 'lib/lp/snappy/tests/test_snap.py'
95--- lib/lp/snappy/tests/test_snap.py 2019-04-01 09:03:46 +0000
96+++ lib/lp/snappy/tests/test_snap.py 2019-04-16 13:16:29 +0000
97@@ -1584,6 +1584,22 @@
98 {"name": "test-snap"},
99 getUtility(ISnapSet).getSnapcraftYaml(branch))
100
101+ def test_getSnapcraftYaml_bzr_build_aux_snap_snapcraft_yaml(self):
102+ def getInventory(unique_name, dirname, *args, **kwargs):
103+ if dirname == "build-aux/snap":
104+ return {"filelist": [{
105+ "filename": "snapcraft.yaml", "file_id": "some-file-id",
106+ }]}
107+ else:
108+ raise BranchFileNotFound("dummy", dirname)
109+
110+ self.useFixture(BranchHostingFixture(
111+ blob=b"name: test-snap")).getInventory = getInventory
112+ branch = self.factory.makeBranch()
113+ self.assertEqual(
114+ {"name": "test-snap"},
115+ getUtility(ISnapSet).getSnapcraftYaml(branch))
116+
117 def test_getSnapcraftYaml_bzr_plain_snapcraft_yaml(self):
118 def getInventory(unique_name, dirname, *args, **kwargs):
119 if dirname == "":
120@@ -1637,6 +1653,19 @@
121 {"name": "test-snap"},
122 getUtility(ISnapSet).getSnapcraftYaml(git_ref))
123
124+ def test_getSnapcraftYaml_git_build_aux_snap_snapcraft_yaml(self):
125+ def getBlob(path, filename, *args, **kwargs):
126+ if filename == "build-aux/snap/snapcraft.yaml":
127+ return b"name: test-snap"
128+ else:
129+ raise GitRepositoryBlobNotFound("dummy", filename)
130+
131+ self.useFixture(GitHostingFixture()).getBlob = getBlob
132+ [git_ref] = self.factory.makeGitRefs()
133+ self.assertEqual(
134+ {"name": "test-snap"},
135+ getUtility(ISnapSet).getSnapcraftYaml(git_ref))
136+
137 def test_getSnapcraftYaml_git_plain_snapcraft_yaml(self):
138 def getBlob(path, filename, *args, **kwargs):
139 if filename == "snapcraft.yaml":