Class: GitProc::RebaseToMaster
- Inherits:
-
Process
- Object
- Process
- GitProc::RebaseToMaster
show all
- Defined in:
- lib/git-process/rebase_to_master.rb
Instance Method Summary
collapse
Methods inherited from Process
#cleanup, #config, #fetch_remote_changes, #gitlib, #is_parked?, #logger, #master_branch, #remote, #run, #workdir
Constructor Details
Returns a new instance of RebaseToMaster.
27
28
29
30
31
32
33
|
# File 'lib/git-process/rebase_to_master.rb', line 27
def initialize(dir, opts)
@keep = opts[:keep]
@pr_number = opts[:prNumber]
@user = opts[:user]
@password = opts[:password]
super
end
|
Instance Method Details
#checkout_pull_request ⇒ Object
67
68
69
|
# File 'lib/git-process/rebase_to_master.rb', line 67
def checkout_pull_request
PullRequest.checkout_pull_request(gitlib, @pr_number, remote.name, remote.repo_name, @user, @password, logger)
end
|
#close_pull_request ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/git-process/rebase_to_master.rb', line 104
def close_pull_request
pr = GitHub::PullRequest.new(gitlib, remote.name, remote.repo_name)
if pr.configuration.get_config_auth_token
begin
if @pr_number
pr.close(@pr_number)
else
mybranches = gitlib.branches()
pull = pr.find_pull_request(config.master_branch, mybranches.current.name)
if pull
pr.close(pull[:number])
else
logger.debug { "There is no pull request for #{mybranches.current.name} against #{config.master_branch}" }
end
end
rescue GitHubService::NoRemoteRepository => exp
logger.debug exp.to_s
end
else
logger.debug 'There is no GitHub auth token defined, so not trying to close a pull request.'
end
end
|
#remove_feature_branch ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/git-process/rebase_to_master.rb', line 72
def remove_feature_branch
mybranches = gitlib.branches
remote_master = mybranches[remote.master_branch_name]
current_branch = mybranches.current
logger.debug { "Removing feature branch (#{current_branch})" }
unless remote_master.contains_all_of(current_branch.name)
raise GitProcessError.new("Branch '#{current_branch.name}' has not been merged into '#{remote.master_branch_name}'")
end
parking_branch = mybranches['_parking_']
if parking_branch
if parking_branch.is_ahead_of(remote_master.name) and
!current_branch.contains_all_of(parking_branch.name)
parking_branch.rename('_parking_OLD_')
logger.warn { bad_parking_branch_msg }
else
parking_branch.delete!
end
end
remote_master.checkout_to_new('_parking_', :no_track => true)
current_branch.delete!(true)
if mybranches["#{remote.name}/#{current_branch.name}"]
gitlib.push(remote.name, nil, nil, :delete => current_branch.name)
end
end
|
#runner ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/git-process/rebase_to_master.rb', line 44
def runner
if remote.exists?
gitlib.fetch(remote.name)
unless @pr_number.nil? or @pr_number.empty?
checkout_pull_request
end
Syncer.rebase_sync(gitlib, true)
current = gitlib.branches.current.name
gitlib.push(remote.name, current, config.master_branch)
unless @keep
close_pull_request
remove_feature_branch
gitlib.delete_sync_control_file!(current) if gitlib.sync_control_file_exists?(current)
end
else
Syncer.rebase_sync(gitlib, true)
end
end
|
#verify_preconditions ⇒ Object