aboutsummaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Rakefile25
1 files changed, 17 insertions, 8 deletions
diff --git a/Rakefile b/Rakefile
index 471b2277..f3ada93d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -247,18 +247,21 @@ end
desc "deploy public directory to github pages"
multitask :push do
puts "## Deploying branch to Github Pages "
+ puts "## Pulling any updates from Github Pages "
+ cd "#{deploy_dir}" do
+ system "git pull"
+ end
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
- puts "\n## copying #{public_dir} to #{deploy_dir}"
+ puts "\n## Copying #{public_dir} to #{deploy_dir}"
cp_r "#{public_dir}/.", deploy_dir
cd "#{deploy_dir}" do
- system "git add ."
- system "git add -u"
+ system "git add -A"
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{deploy_dir} website"
- system "git push origin #{deploy_branch} --force"
+ system "git push origin #{deploy_branch}"
puts "\n## Github Pages deploy complete"
end
end
@@ -304,11 +307,17 @@ task :setup_github_pages, :repo do |t, args|
repo_url = args.repo
else
puts "Enter the read/write url for your repository"
- puts "(For example, 'git@github.com:your_username/your_username.github.com)"
+ puts "(For example, 'git@github.com:your_username/your_username.github.io)"
+ puts " or 'https://github.com/your_username/your_username.github.io')"
repo_url = get_stdin("Repository url: ")
end
- user = repo_url.match(/:([^\/]+)/)[1]
- branch = (repo_url.match(/\/[\w-]+\.github\.com/).nil?) ? 'gh-pages' : 'master'
+ protocol = (repo_url.match(/(^git)@/).nil?) ? 'https' : 'git'
+ if protocol == 'git'
+ user = repo_url.match(/:([^\/]+)/)[1]
+ else
+ user = repo_url.match(/github\.com\/([^\/]+)/)[1]
+ end
+ branch = (repo_url.match(/\/[\w-]+\.github\.(?:io|com)/).nil?) ? 'gh-pages' : 'master'
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
# If octopress is still the origin remote (from cloning) rename it to octopress
@@ -328,7 +337,7 @@ task :setup_github_pages, :repo do |t, args|
end
end
end
- url = "http://#{user}.github.com"
+ url = "http://#{user}.github.io"
url += "/#{project}" unless project == ''
jekyll_config = IO.read('_config.yml')
jekyll_config.sub!(/^url:.*$/, "url: #{url}")