gimp 0.0.3 → 0.1.0

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: 9bc0d185e1b6939980f3b6501584bde1e06d7fa7
4
- data.tar.gz: 6280311aa24f27075437ca359e7efbce4f3f120c
3
+ metadata.gz: 842a3ae347d1837cf8e6a04854450bce2fd24271
4
+ data.tar.gz: 04d023df2c43678b1150cf91349a587a251d8f75
5
5
  SHA512:
6
- metadata.gz: edb2a87d60f34229c3d8fd49cb9fbbdf3d75eca74c087b62cd5860419496df0e8e324aa73f731ad07fb5513de12d780487bbf05308104f0e0ea6fda6691773d3
7
- data.tar.gz: 1d42802ce61c3e666ad4073dfb15d338b2134a91277283db5a93ca2a72f9d6c5e2e9ea3a622de45a0feea481ee985bd47cc7e6c2217f854f49ad5ed0994653d7
6
+ metadata.gz: 8cea25d78d6c3eaa86786fd73f9f7542052c834367377ac5c27270f4d5c3d45a936e50b5b5c39f574094cb53cf0fe51ad077d1966cd98a21485fecc1cba89a67
7
+ data.tar.gz: 09bafc5cc6b88982b7d39720bfc68809917185831ac73176154321e169ccaaee1cf4d7088a1d84520181239050c850203b72e5da37dfa30d0f1c957d3d90f3b6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Gimp
1
+ # GIMP
2
2
 
3
3
  Move issues between GitHub repositories.
4
4
 
@@ -7,7 +7,7 @@ Move issues between GitHub repositories.
7
7
  $ gem install gimp
8
8
  $ gimp --help
9
9
 
10
- Authentication uses GitHub access tokens, go to *Edit profile > Personal access tokens* and click *Generate new token*. The default permissions are fine.
10
+ Authentication uses GitHub access tokens, go to *Your profile > Edit profile > Personal access tokens* and click *Generate new token*. The default permissions are fine.
11
11
 
12
12
  Example usage:
13
13
 
@@ -39,11 +39,11 @@ Remember to add an entry for `.gimp` to your `.gitignore` file so you don't comm
39
39
 
40
40
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
41
 
42
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `gem release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
43
 
44
44
  ## Contributing
45
45
 
46
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gimp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gregbeech/gimp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
47
47
 
48
48
 
49
49
  ## License
data/exe/gimp CHANGED
@@ -2,45 +2,17 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'gimp'
5
+ require 'gimp/options'
5
6
  require 'yaml'
6
7
  require 'hashie/mash'
7
8
 
8
- options = Hashie::Mash.new(File.exist?('.gimp') ? YAML.load_file('.gimp') : {})
9
- opts = OptionParser.new do |opts|
10
- opts.banner = 'Usage: gimp [options]'
11
-
12
- opts.on('-t', '--token ACCESS_TOKEN', 'GitHub access token') do |access_token|
13
- options.access_token = access_token
14
- end
15
- opts.on('-s', '--source SOURCE', 'Source repository') do |source|
16
- options.source = source
17
- end
18
- opts.on('-d', '--destination DESTINATION', 'Destination repository') do |destination|
19
- options.destination = destination
20
- end
21
- opts.on('-i', '--issues ISSUES', Array, 'Issue numbers') do |issues|
22
- options.issues = issues
23
- end
24
- opts.on('--exclude-labels [LABELS]', Array, 'Exclude labels', ' (exclude specific labels if LABELS supplied)') do |labels|
25
- options.labels ||= Hashie::Mash.new
26
- options.labels.exclude = labels || true
27
- end
28
- opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
29
- options.verbose = v
30
- end
31
- opts.on_tail("-h", "--help", "Show this message") do
32
- puts opts
33
- exit
34
- end
35
- opts.on_tail("--version", "Show version") do
36
- puts Gimp::VERSION
37
- exit
38
- end
39
- end
40
-
41
- opts.parse!
42
- unless options.token? && options.source? && options.destination? && options.issues?
43
- puts opts
9
+ options = Gimp::Options.new(File.exist?('.gimp') ? YAML.load_file('.gimp') : {})
10
+ options.parse!(ARGV)
11
+ if options.version?
12
+ puts Gimp::VERSION
13
+ exit
14
+ elsif options.help? || !options.valid?
15
+ puts options.usage
44
16
  exit
45
17
  end
46
18
 
@@ -1,29 +1,28 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'gimp/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "gimp"
6
+ spec.name = 'gimp'
8
7
  spec.version = Gimp::VERSION
9
- spec.authors = ["Greg Beech"]
10
- spec.email = ["greg@gregbeech.com"]
8
+ spec.authors = ['Greg Beech']
9
+ spec.email = ['greg@gregbeech.com']
11
10
 
12
11
  spec.summary = %q{GitHub Issue Moving Program}
13
12
  spec.description = %q{Move issues between GitHub repos from the command line.}
14
- spec.homepage = "https://github.com/gregbeech/gimp"
15
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/gregbeech/gimp'
14
+ spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
17
+ spec.bindir = 'exe'
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
21
20
 
22
- spec.add_dependency "octokit", "~> 4.1"
23
- spec.add_dependency "hashie", "~> 3.4"
21
+ spec.add_dependency 'octokit', '~> 4.1'
22
+ spec.add_dependency 'hashie', '~> 3.4'
24
23
 
25
- spec.add_development_dependency "bundler", "~> 1.10"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.3"
28
- spec.add_development_dependency "gem-release"
24
+ spec.add_development_dependency 'bundler', '~> 1.10'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.3'
27
+ spec.add_development_dependency 'gem-release', '>= 0.7'
29
28
  end
@@ -5,6 +5,7 @@ module Gimp
5
5
  class Mover
6
6
  def initialize(options)
7
7
  @client = Octokit::Client.new(access_token: options.token)
8
+ @options = options
8
9
  @source = options.source
9
10
  @destination = options.destination
10
11
  @exclude_labels = options.labels.exclude if options.labels? && options.labels.exclude?
@@ -18,7 +19,7 @@ module Gimp
18
19
 
19
20
  labels.each { |label| ensure_label(label) }
20
21
  new_issue = @client.create_issue(@destination, issue.title, issue.body,
21
- assignee: issue.assignee ? issue.assignee.login : nil,
22
+ assignee: new_assignee(issue),
22
23
  labels: labels.map(&:name))
23
24
  @client.add_comment(@destination, new_issue.number, "*Issue migrated from #{@source}##{issue.number}*")
24
25
  comments.each { |comment| @client.add_comment(@destination, new_issue.number, comment_text(comment)) }
@@ -44,6 +45,11 @@ module Gimp
44
45
  @known_labels << label.name
45
46
  end
46
47
 
48
+ def new_assignee(issue)
49
+ return nil if @options.unassign? || issue.assignee.nil?
50
+ issue.assignee.login if @client.collaborator?(@destination, issue.assignee.login)
51
+ end
52
+
47
53
  def comment_text(comment)
48
54
  "*@#{comment.user.login} commented at #{comment.created_at}*\n\n---\n\n#{comment.body}"
49
55
  end
@@ -0,0 +1,56 @@
1
+ module Gimp
2
+ class Options < SimpleDelegator
3
+ def initialize(defaults)
4
+ super(@options = Hashie::Mash.new(defaults))
5
+ end
6
+
7
+ def parse!(args)
8
+ parser.parse!(args)
9
+ self
10
+ end
11
+
12
+ def valid?
13
+ @options.token? && @options.source? && @options.destination? && @options.issues?
14
+ end
15
+
16
+ def usage
17
+ parser.to_s
18
+ end
19
+
20
+ private
21
+
22
+ def parser
23
+ @parser ||= OptionParser.new do |opts|
24
+ opts.banner = 'Usage: gimp [options]'
25
+ opts.on('-t', '--token ACCESS_TOKEN', 'GitHub access token') do |access_token|
26
+ @options.access_token = access_token
27
+ end
28
+ opts.on('-s', '--source SOURCE', 'Source repository') do |source|
29
+ @options.source = source
30
+ end
31
+ opts.on('-d', '--destination DESTINATION', 'Destination repository') do |destination|
32
+ @options.destination = destination
33
+ end
34
+ opts.on('-i', '--issues ISSUES', Array, 'Issue numbers') do |issues|
35
+ @options.issues = issues
36
+ end
37
+ opts.on('-u', '--unassign', 'Do not copy the existing assignee') do
38
+ @options.unassign = true
39
+ end
40
+ opts.on('--exclude-labels [LABELS]', Array, 'Exclude labels', ' (exclude specific labels if LABELS supplied)') do |labels|
41
+ @options.labels ||= Hashie::Mash.new
42
+ @options.labels.exclude = labels || true
43
+ end
44
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
45
+ @options.verbose = v
46
+ end
47
+ opts.on_tail("-h", "--help", "Show this message") do
48
+ @options.help = true
49
+ end
50
+ opts.on_tail("--version", "Show version") do
51
+ @options.version = true
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module Gimp
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Beech
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '0.7'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '0.7'
97
97
  description: Move issues between GitHub repos from the command line.
98
98
  email:
99
99
  - greg@gregbeech.com
@@ -115,6 +115,7 @@ files:
115
115
  - exe/gimp
116
116
  - gimp.gemspec
117
117
  - lib/gimp.rb
118
+ - lib/gimp/options.rb
118
119
  - lib/gimp/version.rb
119
120
  homepage: https://github.com/gregbeech/gimp
120
121
  licenses: