jirutka / rake-jekyll

Rake tasks for Jekyll as a gem.
MIT License
30 stars 3 forks source link

Better default deploy branch option #9

Closed razor-x closed 9 years ago

razor-x commented 9 years ago

For username.github.io repos, the master branch is used for serving to GitHub Pages. To auto-detect this I'm using:

t.deploy_branch = -> {
  t.remote_url.match(/github\.io\.git$/) ? 'master' : 'gh-pages'
}
razor-x commented 9 years ago

Actually, to handle the case of forking a user repo, we need

t.deploy_branch = -> {
  user = ENV['TRAVIS_REPO_SLUG'].to_s.split('/').first
  t.remote_url.match(%r{(:|/)#{user}\.github\.io\.git$}) ? 'master' : 'gh-pages'
}
jirutka commented 9 years ago

Why /github\.io\.git$/ isn’t sufficient?

razor-x commented 9 years ago

The obvious scenario I came up with is if you fork someone's io repo, then it will still match that pattern but since the username in the repo name is not yours, it will serve from the gh-pages branch.

For example, if I fork them/them.github.io to me/them.github.io, then me/them.github.io needs to deploy to the gh-pages branch.

jirutka commented 9 years ago

Ah, you’re right. By the way, when the generated content is in the master branch, what’s the source branch?

razor-x commented 9 years ago

I don't think GitHub has the concept of a "source branch". They just designate a special branch to be the one to serve content from (they run Jekyll on that unless you add .nojekyll). How stuff ends up in that branch is up to us. That's one of the reasons I originally submitted #7.

adfernandes commented 9 years ago

:+1:

razor-x commented 9 years ago

Any chance you can add this for v1.1.0?