11
11
module AwestructWebEditor
12
12
class Repository
13
13
14
- attr_reader :name , :uri
14
+ attr_reader :name
15
15
attr_accessor :relative_path
16
16
17
17
def initialize ( content = [ ] )
18
18
@name = content [ 'name' ] || content [ :name ] || ''
19
- @uri = content [ 'uri' ] || content [ :uri ] || ''
20
19
@relative_path = content [ 'relative_path' ] || content [ :relative_path ] || nil
21
20
22
21
log_file = File . new ( File . join ( ( ENV [ 'OPENSHIFT_RUBY_LOG_DIR' ] || 'log' ) , 'application.log' ) , 'a+' )
@@ -67,7 +66,7 @@ def clone_repo
67
66
github = create_github_client
68
67
begin
69
68
@logger . info 'creating github fork'
70
- fork_response = github . fork ( URI ( @settings [ 'repo' ] ) . path [ 1 ..- 1 ] )
69
+ fork_response = github . fork ( @settings [ 'repo' ] )
71
70
rescue Exception => e
72
71
return [ 500 , e . message ]
73
72
end
@@ -80,7 +79,7 @@ def clone_repo
80
79
git . add_remote ( 'upstream' , fork_response . parent . clone_url )
81
80
82
81
@logger . debug 'pulling from git'
83
- Open3 . popen3 ( " git pull upstream master" ) do |_ , _ , stderr , wait_thr |
82
+ Open3 . popen3 ( ' git pull upstream master' ) do |_ , _ , stderr , wait_thr |
84
83
exit_value = wait_thr . value
85
84
@logger . debug "pull exit status: #{ exit_value } "
86
85
error = stderr . readlines . join "\n "
@@ -163,8 +162,7 @@ def commit(message)
163
162
164
163
def fetch_remote ( remote = 'upstream' )
165
164
@logger . info "Fetching remote #{ remote } "
166
- Open3 . popen3 ( "git fetch #{ remote } " ,
167
- :chdir => File . absolute_path ( base_repository_path ) ) do |_ , _ , stderr , wait_thr |
165
+ Open3 . popen3 ( "git fetch #{ remote } " , :chdir => File . absolute_path ( base_repository_path ) ) do |_ , _ , stderr , wait_thr |
168
166
exit_value = wait_thr . value
169
167
@logger . debug "fetch exit status: #{ exit_value } "
170
168
error = stderr . readlines . join "\n "
@@ -173,15 +171,15 @@ def fetch_remote(remote = 'upstream')
173
171
end
174
172
175
173
def create_branch ( branch_name )
176
- upstream_repo = create_github_client . repository ( Octokit ::Repository . from_url @settings [ 'repo' ] )
174
+ upstream_repo = create_github_client . repository ( Octokit ::Repository . new @settings [ 'repo' ] )
177
175
fetch_remote
178
176
@logger . info "creating branch #{ branch_name } based on 'upstream/#{ upstream_repo . master_branch } '"
179
177
system ( "git checkout -b #{ branch_name } upstream/#{ upstream_repo . master_branch } " )
180
178
end
181
179
182
180
def rebase ( overwrite , remote = 'upstream' )
183
181
fetch_remote remote
184
- upstream_repo = create_github_client . repository ( Octokit ::Repository . from_url @settings [ 'repo' ] )
182
+ upstream_repo = create_github_client . repository ( Octokit ::Repository . new @settings [ 'repo' ] )
185
183
Dir . chdir ( File . join @base_repo_dir ) do
186
184
if overwrite
187
185
@logger . debug 'overwriting our files during the rebase'
@@ -216,7 +214,7 @@ def push(remote = 'origin')
216
214
217
215
def pull_request ( title , body )
218
216
github = create_github_client
219
- upstream_repo = Octokit ::Repository . from_url @settings [ 'repo' ]
217
+ upstream_repo = Octokit ::Repository . new @settings [ 'repo' ]
220
218
upstream_response = github . repository ( upstream_repo )
221
219
@logger . info "Issuing a pull request with title - #{ title } and body #{ body } "
222
220
pull_request_result = github . create_pull_request ( upstream_repo ,
0 commit comments