diff mbox

[kteam-tools] verify-release-ready: support other remotes than origin

Message ID 20170629155556.21467-1-cascardo@canonical.com
State New
Headers show

Commit Message

Thadeu Lima de Souza Cascardo June 29, 2017, 3:55 p.m. UTC
If the current branch uses a remote other than origin, check the tag is
pushed in that remote instead of origin. As more branches are kept in
their own repo these days, this allows one to use a single local repo
for those.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 ktl/git.py                        | 12 ++++++++++++
 maintscripts/verify-release-ready |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Stefan Bader July 10, 2017, 12:20 p.m. UTC | #1
On 29.06.2017 17:55, Thadeu Lima de Souza Cascardo wrote:
> If the current branch uses a remote other than origin, check the tag is
> pushed in that remote instead of origin. As more branches are kept in
> their own repo these days, this allows one to use a single local repo
> for those.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---
>  ktl/git.py                        | 12 ++++++++++++
>  maintscripts/verify-release-ready |  3 ++-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/ktl/git.py b/ktl/git.py
> index 9e5cc72b..5c4e270e 100644
> --- a/ktl/git.py
> +++ b/ktl/git.py
> @@ -100,6 +100,18 @@ class Git:
>              raise GitError("no current branch")
>          return result[0].replace("refs/heads/", "")
>  
> +    # remote
> +    #
> +    # Return a string that is the remote this branch tracks or origin.
> +    #
> +    @classmethod
> +    def remote(cls):
> +        branch = cls.current_branch()
> +        status, result = run_command("git config branch.%s.remote" % branch, cls.debug)
> +        if status != 0:
> +            return "origin"
> +        return result[0]
> +
>      # show
>      #
>      @classmethod
> diff --git a/maintscripts/verify-release-ready b/maintscripts/verify-release-ready
> index b22c5aa4..7805b462 100755
> --- a/maintscripts/verify-release-ready
> +++ b/maintscripts/verify-release-ready
> @@ -312,7 +312,8 @@ class VerifyReleaseReady():
>          else:
>              # Verify tag has been pushed!
>              msg = 'tag pushed'
> -            status, result = run_command("git ls-remote --tags origin %s" % expected)
> +            branch = Git.remote()
> +            status, result = run_command("git ls-remote --tags %s %s" % (branch, expected))
>              if status == 0 and expected in result[0]:
>                  s.status(msg, True)
>              else:
>
Marcelo Henrique Cerri July 19, 2017, 7:18 p.m. UTC | #2

Thadeu Lima de Souza Cascardo July 19, 2017, 7:30 p.m. UTC | #3
Applied to kteam-tools.

Thanks.
Cascardo.
diff mbox

Patch

diff --git a/ktl/git.py b/ktl/git.py
index 9e5cc72b..5c4e270e 100644
--- a/ktl/git.py
+++ b/ktl/git.py
@@ -100,6 +100,18 @@  class Git:
             raise GitError("no current branch")
         return result[0].replace("refs/heads/", "")
 
+    # remote
+    #
+    # Return a string that is the remote this branch tracks or origin.
+    #
+    @classmethod
+    def remote(cls):
+        branch = cls.current_branch()
+        status, result = run_command("git config branch.%s.remote" % branch, cls.debug)
+        if status != 0:
+            return "origin"
+        return result[0]
+
     # show
     #
     @classmethod
diff --git a/maintscripts/verify-release-ready b/maintscripts/verify-release-ready
index b22c5aa4..7805b462 100755
--- a/maintscripts/verify-release-ready
+++ b/maintscripts/verify-release-ready
@@ -312,7 +312,8 @@  class VerifyReleaseReady():
         else:
             # Verify tag has been pushed!
             msg = 'tag pushed'
-            status, result = run_command("git ls-remote --tags origin %s" % expected)
+            branch = Git.remote()
+            status, result = run_command("git ls-remote --tags %s %s" % (branch, expected))
             if status == 0 and expected in result[0]:
                 s.status(msg, True)
             else: