Last active
November 18, 2020 21:34
Automatically setup an upstream remote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
import groovy.json.JsonSlurper | |
def (_, owner, repo) = ('git remote get-url origin'.execute().text =~ /\/([^\/]+)\/([^\/]+)$/)[0] | |
def parentUrl = new JsonSlurper().parse(new URL("https://api.github.com/repos/$owner/$repo")).parent.html_url | |
"git remote add upstream $parentUrl".execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment