Repository: emissary-ingress/emissary

Issue:
Ambassador is too quick to decide not to build
Forking this from #84; @yiakwy raises a good point about the build, but it's separate from the doc issues that are the rest of #84.

Basically, if you clone Ambassador and run a build in that pristine clone, it'll tell you it has nothing to do, rather than building you a set of Docker images and pushing them to your own repo. This is silly: the CI pipeline should indeed not build with no changes if it somehow gets triggered, but a user typing `make` by hand should absolutely get artifacts out.


Discussion:

Resolving patch:
diff --git a/scripts/versioner.py b/scripts/versioner.py
--- a/scripts/versioner.py
+++ b/scripts/versioner.py
@@ -110,9 +110,10 @@ def recent_commits(self, since_tag=None):
 
                 yield commitID, subject
 
-    def next_version(self, magic_pre=False, since_tag=None, reduced_zero=True, commit_map=None,
-                     pre_release=None, build=None):
-        rdelta = ReleaseDelta(self, magic_pre=magic_pre, 
+    def next_version(self, magic_pre=False, since_tag=None, reduced_zero=True,
+                     only_if_changes=False, pre_release=None, build=None,
+                     commit_map=None):
+        rdelta = ReleaseDelta(self, only_if_changes=only_if_changes, magic_pre=magic_pre,
                               since_tag=since_tag, reduced_zero=reduced_zero,
                               commit_map=commit_map, pre_release=pre_release, build=build)
 
@@ -154,11 +155,12 @@ class ReleaseDelta(object):
     """ how new commits affect project version """
     log = logging.getLogger("ReleaseDelta")
 
-    def __init__(self, vbr, magic_pre=False, since_tag=None,
+    def __init__(self, vbr, only_if_changes=False, magic_pre=False, since_tag=None,
                  reduced_zero=True, commit_map=None,
                  pre_release=None, build=None):
         self.vbr = vbr
         self.is_dirty = vbr.is_dirty
+        self.only_if_changes = only_if_changes
         self.magic_pre = magic_pre
         self.since_tag = since_tag
         self.pre_release = pre_release
@@ -304,8 +306,11 @@ def next_version(self):
                            (self.vbr.version, version))
 
             return version
-        else:
+        elif self.only_if_changes:
             return None
+        else:
+            # Just return the old version.
+            return version
 
 class VersionedRepo (object):
     """ Representation of a git repo that follows our versioning rules """
@@ -374,6 +379,7 @@ def tag_version(self, version, commit):
         --pre=<pre-release-tag>    explicitly set the prerelease number
         --build=<build-tag>        explicitly set the build number
         --since=<since-tag>        override the tag of the last release
+        --only-if-changes          don't build if there are no changes since last tag
     """
 
     args = docopt(__doc__, version="versioner {0}".format("0.1.0"))
@@ -399,11 +405,12 @@ def tag_version(self, version, commit):
     # }
 
     next_version = vbr.next_version(magic_pre=args.get('--magic-pre', False),
-                               pre_release=args.get('--pre', None),
-                               build=args.get('--build', None),
-                               since_tag=args.get('--since', None),
-                               reduced_zero=False)
-    #                           commit_map=commit_map)
+                                    pre_release=args.get('--pre', None),
+                                    build=args.get('--build', None),
+                                    since_tag=args.get('--since', None),
+                                    only_if_changes=args.get('--only-if-changes', False),
+                                    reduced_zero=False)
+                                    # commit_map=commit_map)
 
     if next_version:
         print(next_version)


Test patch: