zd_hire 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/zd_hire +37 -0
  3. data/lib/zd_hire/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0971f5f3780f1088ee0d4c38638decdc2016a8fc'
4
- data.tar.gz: 48025579e091a34a92db35c2fe60c08fcb5c6290
3
+ metadata.gz: 904dc6c89277052207e64e23e70d0f1367b81a40
4
+ data.tar.gz: 2de15e3b05ff7e28ad81462d465bb629576a24bf
5
5
  SHA512:
6
- metadata.gz: bb8f4e78d4b0f068a15ef9bd16fd9ebbd5cff7738e477d3c6fee7726efa774f3f2c943ed540b9068a95fc0c9dde0b0c4729c71cd346c211b2be5f7b448cd3f16
7
- data.tar.gz: 7e21272192a87eec7d523cfd8739081b5394c9171f3b9441e6c40b9d402e2d618bb3d91d098029df5c166e5e8b1daf62a1d9d5c9a0f4e6620fd4ec3b38cf3d6f
6
+ metadata.gz: 2ad5563e7ffdaaa88e4770e3d51820bbf6ceee26e3af10875ca0db0ca363c444d3e882f39cf30a89e385e0961785b5891d1dd5cd52118a017beccdcebdc81291
7
+ data.tar.gz: 0e88e993f4a938935cc88418b356d175f2406bb6182e30543045d209d15e9522194dae2cef3799feb09fa6c66611429454c98eebbb9bd59ab91e3d49aec4fcde
data/bin/zd_hire CHANGED
@@ -103,6 +103,35 @@ command :clone do |c|
103
103
  end
104
104
  end
105
105
 
106
+ command :pr do |c|
107
+ c.action do |args, options|
108
+
109
+ end
110
+ end
111
+
112
+ def create_pr(new_repo)
113
+ origin_pull_requests.each {|pr| say "[#{pr.number}] #{pr.head.ref}: #{pr.title}" }
114
+ pr_number = ask('Which Pull Request? ') do |q|
115
+ q.character = true
116
+ end
117
+ selected = origin_pull_requests.detect {|pr| pr.number.to_i == pr_number.to_i }
118
+ exit unless selected
119
+ branch = selected.head.ref
120
+ command = [
121
+ "cd #{new_repo.name}",
122
+ "git checkout -b #{branch}",
123
+ "git pull #{config.local_path} #{branch} --allow-unrelated-histories --no-edit",
124
+ "git reset $(git merge-base master #{branch})",
125
+ 'git add -A',
126
+ "git commit -m '#{selected.title}'",
127
+ "git push origin #{branch}"
128
+ ].join(' && ')
129
+
130
+ `#{command}`
131
+ sleep 1
132
+ github.create_pull_request(new_repo.full_name, 'master', branch, selected.title, selected.body)
133
+ end
134
+
106
135
  def origin_default_issue
107
136
  @df ||= origin_repo_issues.detect{|issue| issue.labels.any?{ |l| l.name == DEFAULT_ISSUE_LABEL} }
108
137
  end
@@ -132,6 +161,10 @@ def origin_repo_issues(options = {})
132
161
  @rp ||= github.issues(config.origin_repo, options).reject(&:pull_request)
133
162
  end
134
163
 
164
+ def origin_pull_requests
165
+ @prs ||= github.pull_requests(config.origin_repo)
166
+ end
167
+
135
168
  def copy_and_report_issues(target)
136
169
  issues = presentable_issues
137
170
  issues.each { |i| say "#{i.number}: #{i.title}" }
@@ -198,6 +231,10 @@ def create_project(target)
198
231
  copy_and_report_issues(new_repo.full_name)
199
232
  end
200
233
 
234
+ if agree("Would you like to copy a Pull Request(y/n) ", true)
235
+ create_pr(new_repo)
236
+ end
237
+
201
238
  if agree('Would you like to open the project in your browser?(y/n) ', true)
202
239
  system "open #{new_repo.html_url}"
203
240
  end
@@ -1,3 +1,3 @@
1
1
  module ZdHire
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zd_hire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Angelim