Rakefile in u3d-1.1.3 vs Rakefile in u3d-1.1.4

- old
+ new

@@ -85,10 +85,36 @@ UI.user_error!(error_message) end output end +### +### see https://github.com/github/hub/issues/2055 +def ensure_hub! + require 'English' + `which hub` + raise "Missing hub command. This script requires the hub command. Get it from https://hub.github.com" unless $CHILD_STATUS.exitstatus.zero? +end + +def hub_config + require 'YAML' + File.open(File.expand_path("~/.config/hub"), 'r:bom|utf-8') { |f| Psych.safe_load(f.read) } +end + +def hub_user(server) + hub_config[server][0]['user'] +end + +def hub_fork_remote_name + server = 'github.com' + + user = hub_user(server) + + `git remote -v`.split("\n").map(&:split).select { |a| a[2] == '(push)' && a[1] =~ /#{server}.#{user}/ }.first[0] +end +### + task :ensure_git_clean do branch = run_command('git rev-parse --abbrev-ref HEAD', "Couldn't get current git branch").strip UI.user_error!("You are not on 'master' but on '#{branch}'") unless branch == "master" output = run_command('git status --porcelain', "Couldn't get git status") UI.user_error!("git status not clean:\n#{output}") unless output == "" @@ -124,12 +150,14 @@ UI.user_error! "Pre release stopped by user." unless UI.confirm("CHANGELOG PR for version #{nextversion}. Confirm?") msg = "Preparing release for #{nextversion}" sh 'git add CHANGELOG.md' sh "git commit -m '#{msg}'" - sh "git push lacostej" # FIXME: hardcoded - # FIXME: check hub present - sh "hub pull-request -m '#{msg}'" # requires hub pre-release " -l nochangelog" + + ensure_hub! + hub_remote = hub_fork_remote_name + sh "git push #{hub_remote}" + sh "hub pull-request -m '#{msg}' -l nochangelog" sh 'git checkout master' sh "git branch -D #{pr_branch}" end desc 'Bump the version number to the version entered interactively; pushes a commit to master'