← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/snapcraft-yaml-more-paths into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/snapcraft-yaml-more-paths into lp:launchpad.

Commit message:
Consider snap/snapcraft.yaml as well as other paths for new snaps.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1659085 in Launchpad itself: "snapcraft needs to migrate to a snap directory"
  https://bugs.launchpad.net/launchpad/+bug/1659085

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snapcraft-yaml-more-paths/+merge/316084

snap/snapcraft.yaml comes first, to match the logic in snapcraft itself.

The strings are increasingly ugly, but hopefully they won't get too much worse from here ...
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snapcraft-yaml-more-paths into lp:launchpad.
=== modified file 'lib/lp/snappy/browser/snap.py'
--- lib/lp/snappy/browser/snap.py	2017-01-16 22:27:56 +0000
+++ lib/lp/snappy/browser/snap.py	2017-02-01 09:41:31 +0000
@@ -438,10 +438,14 @@
             try:
                 try:
                     blob = self.context.repository.getBlob(
-                        'snapcraft.yaml', self.context.name)
+                        'snap/snapcraft.yaml', self.context.name)
                 except GitRepositoryBlobNotFound:
-                    blob = self.context.repository.getBlob(
-                        '.snapcraft.yaml', self.context.name)
+                    try:
+                        blob = self.context.repository.getBlob(
+                            'snapcraft.yaml', self.context.name)
+                    except GitRepositoryBlobNotFound:
+                        blob = self.context.repository.getBlob(
+                            '.snapcraft.yaml', self.context.name)
                 # Beware of unsafe yaml.load()!
                 store_name = yaml.safe_load(blob).get('name')
             except GitRepositoryScanFault:

=== modified file 'lib/lp/snappy/browser/tests/test_snap.py'
--- lib/lp/snappy/browser/tests/test_snap.py	2017-01-16 22:27:56 +0000
+++ lib/lp/snappy/browser/tests/test_snap.py	2017-02-01 09:41:31 +0000
@@ -493,6 +493,20 @@
         self.assertIn('store_name', initial_values)
         self.assertEqual('test-snap', initial_values['store_name'])
 
+    def test_initial_name_extraction_git_plain_snapcraft_yaml(self):
+        def getBlob(filename, *args, **kwargs):
+            if filename == "snapcraft.yaml":
+                return "name: test-snap"
+            else:
+                raise GitRepositoryBlobNotFound()
+
+        [git_ref] = self.factory.makeGitRefs()
+        git_ref.repository.getBlob = getBlob
+        view = create_initialized_view(git_ref, "+new-snap")
+        initial_values = view.initial_values
+        self.assertIn('store_name', initial_values)
+        self.assertIsNone(initial_values['store_name'])
+
     def test_initial_name_extraction_git_dot_snapcraft_yaml(self):
         def getBlob(filename, *args, **kwargs):
             if filename == ".snapcraft.yaml":

=== modified file 'lib/lp/snappy/interfaces/snap.py'
--- lib/lp/snappy/interfaces/snap.py	2017-01-16 22:27:56 +0000
+++ lib/lp/snappy/interfaces/snap.py	2017-02-01 09:41:31 +0000
@@ -425,22 +425,23 @@
         title=_("Bazaar branch"), schema=IBranch, vocabulary="Branch",
         required=False, readonly=False,
         description=_(
-            "A Bazaar branch containing a snapcraft.yaml or .snapcraft.yaml "
-            "recipe at the top level.")))
+            "A Bazaar branch containing a snap/snapcraft.yaml, "
+            "snapcraft.yaml, or .snapcraft.yaml recipe at the top level.")))
 
     git_repository = exported(ReferenceChoice(
         title=_("Git repository"),
         schema=IGitRepository, vocabulary="GitRepository",
         required=False, readonly=True,
         description=_(
-            "A Git repository with a branch containing a snapcraft.yaml or "
-            ".snapcraft.yaml recipe at the top level.")))
+            "A Git repository with a branch containing a snap/snapcraft.yaml, "
+            "snapcraft.yaml, or .snapcraft.yaml recipe at the top level.")))
 
     git_repository_url = exported(URIField(
         title=_("Git repository URL"), required=False, readonly=True,
         description=_(
             "The URL of a Git repository with a branch containing a "
-            "snapcraft.yaml or .snapcraft.yaml recipe at the top level."),
+            "snap/snapcraft.yaml, snapcraft.yaml, or .snapcraft.yaml recipe "
+            "at the top level."),
         allowed_schemes=["git", "http", "https"],
         allow_userinfo=True,
         allow_port=True,
@@ -451,22 +452,22 @@
     git_path = exported(TextLine(
         title=_("Git branch path"), required=False, readonly=True,
         description=_(
-            "The path of the Git branch containing a snapcraft.yaml or "
-            ".snapcraft.yaml recipe at the top level.")))
+            "The path of the Git branch containing a snap/snapcraft.yaml, "
+            "snapcraft.yaml, or .snapcraft.yaml recipe at the top level.")))
 
     git_ref = exported(Reference(
         IGitRef, title=_("Git branch"), required=False, readonly=False,
         description=_(
-            "The Git branch containing a snapcraft.yaml or .snapcraft.yaml "
-            "recipe at the top level.")))
+            "The Git branch containing a snap/snapcraft.yaml, snapcraft.yaml, "
+            "or .snapcraft.yaml recipe at the top level.")))
 
     auto_build = exported(Bool(
         title=_("Automatically build when branch changes"),
         required=True, readonly=False,
         description=_(
             "Whether this snap package is built automatically when the branch "
-            "containing its snapcraft.yaml or .snapcraft.yaml recipe "
-            "changes.")))
+            "containing its snap/snapcraft.yaml, snapcraft.yaml, or "
+            ".snapcraft.yaml recipe changes.")))
 
     auto_build_archive = exported(Reference(
         IArchive, title=_("Source archive for automatic builds"),

=== modified file 'lib/lp/snappy/templates/snap-new.pt'
--- lib/lp/snappy/templates/snap-new.pt	2017-01-16 22:27:56 +0000
+++ lib/lp/snappy/templates/snap-new.pt	2017-02-01 09:41:31 +0000
@@ -15,8 +15,8 @@
       Core</a>.  Launchpad can build snap packages using <a
       href="https://developer.ubuntu.com/en/snappy/snapcraft/";>snapcraft</a>,
       from any Git or Bazaar branch on Launchpad that has a
-      <tt>snapcraft.yaml</tt> or <tt>.snapcraft.yaml</tt> file at its top
-      level.
+      <tt>snap/snapcraft.yaml</tt>, <tt>snapcraft.yaml</tt>, or
+      <tt>.snapcraft.yaml</tt> file at its top level.
     </p>
   </div>
 


Follow ups