gimp 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38328a6e29e04cc389755677f23661f86811f8f4
4
- data.tar.gz: 5f869167dd509988da53af4555beb1606242b0b4
3
+ metadata.gz: 2efc54d0ab69a86eb2e8044b7aa483471014cd39
4
+ data.tar.gz: 3813510a831fb99adc1ee7bcbb49c36c14eda671
5
5
  SHA512:
6
- metadata.gz: 2b0866f56e60f4fdb0b1403e631bc6354ad7b35641cd5fd1b816e39d7f380c6d4f7c4d7d7221419ac4230514d72bbeef4ec3e7cbe4829b23771041c19b2bbfd3
7
- data.tar.gz: fc58da08c9cd1e22cdd3ee823cea94ab8eed3cc13ed1954bc4cb788ca1dd3ab0405702886791a6fae40309ec0f10dea6c01ca94ee6c286546013d1ce962fadf2
6
+ metadata.gz: 163112534431caf1ae915651794f1c892974093a913af39665ee19325314690aa23e3473c8c345c203b3e47f7ebc382c7268b8c23e84da8e463af3e8d19bbdec
7
+ data.tar.gz: 5d5b8d63d6e11c088b0a1450199027914346b510992f4bf7b224f4d3a8546aa5969284d7de057f1c5f1cbf263b4ed113c504ad3d6ece1b46923d4c789aff3619
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .ruby-gemset
11
+ .ruby-version
data/exe/gimp ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'gimp'
5
+
6
+ options = {}
7
+ OptionParser.new do |opts|
8
+ opts.banner = 'Usage: gimp [options]'
9
+
10
+ opts.on('-s', '--source SOURCE', 'Source repository') do |source|
11
+ options[:source] = source
12
+ end
13
+ opts.on('-d', '--destination DESTINATION', 'Destination repository') do |destination|
14
+ options[:destination] = destination
15
+ end
16
+ opts.on('-i', '--issues ISSUES', Array, 'Issue numbers') do |issues|
17
+ options[:issues] = issues
18
+ end
19
+ opts.on('-t', '--access-token ACCESS_TOKEN', 'GitHub access token') do |access_token|
20
+ options[:access_token] = access_token
21
+ end
22
+ opts.on('--exclude-labels [LABELS]', Array, 'Exclude labels', ' (exclude specific labels if LABELS supplied)') do |labels|
23
+ options[:exclude_labels] = labels
24
+ end
25
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
26
+ options[:verbose] = v
27
+ end
28
+ opts.on_tail("-h", "--help", "Show this message") do
29
+ puts opts
30
+ exit
31
+ end
32
+ end.parse!
33
+
34
+ mover = Gimp::Mover.new(options)
35
+ options[:issues].each do |id|
36
+ new_id = mover.move_issue(id)
37
+ puts "#{options[:source]}##{id} -> #{options[:destination]}##{new_id}"
38
+ end
data/gimp.gemspec CHANGED
@@ -19,7 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency "octokit", "~> 4.1"
23
+
22
24
  spec.add_development_dependency "bundler", "~> 1.10"
23
25
  spec.add_development_dependency "rake", "~> 10.0"
24
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "gem-release"
25
28
  end
data/lib/gimp.rb CHANGED
@@ -1,5 +1,45 @@
1
+ require "octokit"
1
2
  require "gimp/version"
2
3
 
3
4
  module Gimp
4
- # Your code goes here...
5
+ class Mover
6
+ def initialize(options)
7
+ @client = Octokit::Client.new(access_token: options[:access_token])
8
+ @source = options[:source]
9
+ @destination = options[:destination]
10
+ @exclude_labels = options[:exclude_labels] || []
11
+ @known_labels = Set.new
12
+ end
13
+
14
+ def move_issue(id)
15
+ issue = @client.issue(@source, id)
16
+ labels = @client.labels_for_issue(@source, id)
17
+ comments = @client.issue_comments(@source, id)
18
+
19
+ labels.each { |label| ensure_label(label) }
20
+ new_issue = @client.create_issue(@destination, issue.title, issue.body,
21
+ assignee: issue.assignee ? issue.assignee.login : nil,
22
+ labels: labels.map(&:name) - @exclude_labels)
23
+ @client.add_comment(@destination, new_issue.number, "*Issue migrated from #{@source}##{issue.number}*")
24
+ comments.each { |comment| @client.add_comment(@destination, new_issue.number, comment_text(comment)) }
25
+
26
+ @client.close_issue(@source, id)
27
+ new_issue.number
28
+ end
29
+
30
+ private
31
+
32
+ def ensure_label(label)
33
+ return if @exclude_labels.include?(label.name) || @known_labels.include?(label.name)
34
+ @client.label(@destination, label.name)
35
+ @known_labels << label.name
36
+ rescue Octokit::NotFound
37
+ @client.add_label(@destination, label.name, label.color)
38
+ @known_labels << label.name
39
+ end
40
+
41
+ def comment_text(comment)
42
+ "*@#{comment.user.login} commented at #{comment.created_at}*\n\n---\n\n#{comment.body}"
43
+ end
44
+ end
5
45
  end
data/lib/gimp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gimp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimp
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
  - Greg Beech
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,10 +66,25 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gem-release
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Move issues between GitHub repos from the command line.
56
84
  email:
57
85
  - greg@gregbeech.com
58
- executables: []
86
+ executables:
87
+ - gimp
59
88
  extensions: []
60
89
  extra_rdoc_files: []
61
90
  files:
@@ -69,6 +98,7 @@ files:
69
98
  - Rakefile
70
99
  - bin/console
71
100
  - bin/setup
101
+ - exe/gimp
72
102
  - gimp.gemspec
73
103
  - lib/gimp.rb
74
104
  - lib/gimp/version.rb