Commit 943c3668 authored by Rob Lemley's avatar Rob Lemley
Browse files

Bug 1831003 - Use requested tag when updating third party code with mach vendor. r=tjr

Fixes "mach vendor -r [tag]" so that it will update to the requested tag rather
than always updating to the latest.

Differential Revision: https://phabricator.services.mozilla.com/D176973
parent a8bc4a00
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -33,21 +33,34 @@ class BaseHost:
                check=True,
            )
            os.chdir("/".join([temp_repo_clone, self.manifest["origin"]["name"]]))
            latest_tag = subprocess.run(
            if revision == "HEAD":
                tag = subprocess.run(
                    ["git", "--no-pager", "tag", "--sort=creatordate"],
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    universal_newlines=True,
                    check=True,
                ).stdout.splitlines()[-1]
            latest_tag_timestamp = subprocess.run(
            else:
                try:
                    tag = subprocess.run(
                        ["git", "--no-pager", "tag", "-l", revision],
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE,
                        universal_newlines=True,
                        check=True,
                    ).stdout.splitlines()[-1]
                except IndexError:  # 0 lines of output, the tag does not exist
                    raise Exception(f"Requested tag {revision} not found in source.")

            tag_timestamp = subprocess.run(
                [
                    "git",
                    "log",
                    "-1",
                    "--date=iso8601-strict",
                    "--format=%ad",
                    latest_tag,
                    tag,
                ],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
@@ -55,7 +68,7 @@ class BaseHost:
                check=True,
            ).stdout.splitlines()[-1]
            os.chdir(starting_directory)
            return (latest_tag, latest_tag_timestamp)
            return tag, tag_timestamp

    def upstream_snapshot(self, revision):
        raise Exception("Unimplemented for this subclass...")