Skip to content

Commit

Permalink
Add support for mirror repositories
Browse files Browse the repository at this point in the history
When using mirror repositories, git doesn't allow you to push a single
refspec or tag.  Instead, it always pushes an exact copy of your current
repo, all reachable hashes and all tags.  When we have a mirror repo, we
only need to push it once, no matter how many tags we might be creating
releases for.

Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
dledford committed Mar 25, 2017
1 parent cf5c7dc commit 438e323
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/github-release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def repo_url
log_val(@repo_url)
end

def remote_mirror
@remote_mirror ||= git_config("remote.#{remote_name}.mirror")
log_val(@remote_mirror)
end

def remote_name
@remote_name ||= git_config("release.remote", "origin")
log_val(@remote_name)
Expand All @@ -128,8 +133,15 @@ def git_config(item, default = nil)
end

def create_release(tag, prerelease)
puts "Pushing to #{remote_name}..."
system("git push #{remote_name} tag #{tag}")
@pushed ||= false
if remote_mirror == "true" && @pushed == false
puts "Pushing to #{remote_name}..."
system("git push #{remote_name}")
@pushed = true
elsif remote_mirror != "true"
puts "Pushing #{tag} to #{remote_name}..."
system("git push #{remote_name} tag #{tag}")
end

print "Creating a release for #{tag}..."
msg = `git tag -l -n1000 '#{tag}'`
Expand Down

0 comments on commit 438e323

Please sign in to comment.