fix opening PR from fork
This commit is contained in:
parent
2b132c0802
commit
de8c088d15
@ -713,24 +713,19 @@ module GitHub
|
|||||||
tap_remote_repo = info[:tap_remote_repo] || tap.full_name
|
tap_remote_repo = info[:tap_remote_repo] || tap.full_name
|
||||||
pr_message = info[:pr_message]
|
pr_message = info[:pr_message]
|
||||||
pr_title = info[:pr_title]
|
pr_title = info[:pr_title]
|
||||||
|
|
||||||
commits = info[:commits]
|
commits = info[:commits]
|
||||||
username = tap.user
|
|
||||||
|
|
||||||
remote_url = Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
remote_url = Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
||||||
|
username = tap.user
|
||||||
|
|
||||||
tap.path.cd do
|
tap.path.cd do
|
||||||
require "utils/popen"
|
|
||||||
git_dir = Utils.popen_read("git", "rev-parse", "--git-dir").chomp
|
|
||||||
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
|
|
||||||
unless args.commit?
|
|
||||||
if args.no_fork?
|
if args.no_fork?
|
||||||
remote_url = Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
remote_url = Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
||||||
add_auth_token_to_url!(remote_url)
|
|
||||||
username = tap.user
|
username = tap.user
|
||||||
|
add_auth_token_to_url!(remote_url)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
forked_repo_info!(tap_remote_repo, org: args.fork_org)
|
remote_url, username = forked_repo_info!(tap_remote_repo, org: args.fork_org)
|
||||||
rescue *API::ERRORS => e
|
rescue *API::ERRORS => e
|
||||||
commits.each do |commit|
|
commits.each do |commit|
|
||||||
commit[:sourcefile_path].atomic_write(commit[:old_contents])
|
commit[:sourcefile_path].atomic_write(commit[:old_contents])
|
||||||
@ -739,8 +734,12 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
safe_system "git", "fetch", "--unshallow", "origin" if shallow
|
next if args.dry_run?
|
||||||
end
|
|
||||||
|
require "utils/popen"
|
||||||
|
git_dir = Utils.popen_read("git", "rev-parse", "--git-dir").chomp
|
||||||
|
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
|
||||||
|
safe_system "git", "fetch", "--unshallow", "origin" if !args.commit? && shallow
|
||||||
safe_system "git", "checkout", "--no-track", "-b", branch, "#{remote}/#{remote_branch}" unless args.commit?
|
safe_system "git", "checkout", "--no-track", "-b", branch, "#{remote}/#{remote_branch}" unless args.commit?
|
||||||
Utils::Git.set_name_email!
|
Utils::Git.set_name_email!
|
||||||
end
|
end
|
||||||
@ -758,14 +757,6 @@ module GitHub
|
|||||||
changed_files += additional_files if additional_files.present?
|
changed_files += additional_files if additional_files.present?
|
||||||
|
|
||||||
if args.dry_run? || (args.write_only? && !args.commit?)
|
if args.dry_run? || (args.write_only? && !args.commit?)
|
||||||
remote_url = if args.no_fork?
|
|
||||||
Utils.popen_read("git", "remote", "get-url", "--push", "origin").chomp
|
|
||||||
else
|
|
||||||
fork_message = "try to fork repository with GitHub API" \
|
|
||||||
"#{" into `#{args.fork_org}` organization" if args.fork_org}"
|
|
||||||
ohai fork_message
|
|
||||||
"FORK_URL"
|
|
||||||
end
|
|
||||||
ohai "git checkout --no-track -b #{branch} #{remote}/#{remote_branch}"
|
ohai "git checkout --no-track -b #{branch} #{remote}/#{remote_branch}"
|
||||||
ohai "git fetch --unshallow origin" if shallow
|
ohai "git fetch --unshallow origin" if shallow
|
||||||
ohai "git add #{changed_files.join(" ")}"
|
ohai "git add #{changed_files.join(" ")}"
|
||||||
@ -784,7 +775,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return if args.commit?
|
return if args.commit? || args.dry_run?
|
||||||
|
|
||||||
tap.path.cd do
|
tap.path.cd do
|
||||||
system_command!("git", args: ["push", "--set-upstream", remote_url, "#{branch}:#{branch}"],
|
system_command!("git", args: ["push", "--set-upstream", remote_url, "#{branch}:#{branch}"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user