(gh-pages) Need more control for the branch we push to #5

Open
dreamcat4 opened this Issue Apr 4, 2010 · 0 comments

Comments

Projects
None yet
1 participant
Collaborator

dreamcat4 commented Apr 4, 2010

Hi!
In the 0.1.0 Grancher interface, we have:

g.branch = "master"
g.push

Grancher assumes that these branch names or refspec are identical on both the local and remote side. The current implementation of Grancher.push looks like this:

# Pushes the branch to the remote.
def push
  gash.send(:git, 'push', @push_to, @branch + ':refs/heads/' + @branch)
end

We want to change this because of a new feature in jeweler, which now requires grancher. We hope to improve this control to also allow pushing to an arbitrary git refspec.

Reason:

For the gh-pages root repo "user.github.com" in certain cases where the gem repository has its own github account (eg rails/rails). And that account wants to host its pages on "rails.github.com" instead of "rails.github.com/rails".

Proposed changes:

At the moment, what jeweler is doing is to re-open the Grancher class and override a couple of methods. But clearly we would like to see grancher improved, and so to remove this hack from jeweler. This change is backwards compatible. It allows also the usage of the full git refspec syntax +<src>:<dst>. We just add a new :refspec accessor which is mutually exclusive to the branch accessor.

Code:

class Grancher
  attr_accessor :refspec

  def refspec=(refspec)
    # <EDIT>
    # @branch = nil
    @branch = refspec.match(/^\+?(.*)\:/)[1] || "master"
    # </EDIT>
    @refspec = refspec
  end

  def branch=(branch)
    @refspec = "#{branch}:refs/heads/#{branch}"
    @branch = branch
  end

  def push
    gash.send(:git, 'push', @push_to, @refspec)
  end
end

We could also fix the other issue at the same time, for better checking to avoid an invalid blob. Shall send you a pull request later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment