gimp 0.0.2 → 0.0.3

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: 2efc54d0ab69a86eb2e8044b7aa483471014cd39
4
- data.tar.gz: 3813510a831fb99adc1ee7bcbb49c36c14eda671
3
+ metadata.gz: 9bc0d185e1b6939980f3b6501584bde1e06d7fa7
4
+ data.tar.gz: 6280311aa24f27075437ca359e7efbce4f3f120c
5
5
  SHA512:
6
- metadata.gz: 163112534431caf1ae915651794f1c892974093a913af39665ee19325314690aa23e3473c8c345c203b3e47f7ebc382c7268b8c23e84da8e463af3e8d19bbdec
7
- data.tar.gz: 5d5b8d63d6e11c088b0a1450199027914346b510992f4bf7b224f4d3a8546aa5969284d7de057f1c5f1cbf263b4ed113c504ad3d6ece1b46923d4c789aff3619
6
+ metadata.gz: edb2a87d60f34229c3d8fd49cb9fbbdf3d75eca74c087b62cd5860419496df0e8e324aa73f731ad07fb5513de12d780487bbf05308104f0e0ea6fda6691773d3
7
+ data.tar.gz: 1d42802ce61c3e666ad4073dfb15d338b2134a91277283db5a93ca2a72f9d6c5e2e9ea3a622de45a0feea481ee985bd47cc7e6c2217f854f49ad5ed0994653d7
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  .ruby-gemset
11
11
  .ruby-version
12
+ .gimp
data/README.md CHANGED
@@ -1,28 +1,39 @@
1
1
  # Gimp
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gimp`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Move issues between GitHub repositories.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Usage
6
6
 
7
- ## Installation
7
+ $ gem install gimp
8
+ $ gimp --help
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Authentication uses GitHub access tokens, go to *Edit profile > Personal access tokens* and click *Generate new token*. The default permissions are fine.
10
11
 
11
- ```ruby
12
- gem 'gimp'
13
- ```
12
+ Example usage:
14
13
 
15
- And then execute:
14
+ $ gimp --token your-access-token --source gregbeech/test-1 --destination gregbeech/test-2 --exclude-labels 'help wanted',question --issues 23,47
16
15
 
17
- $ bundle
16
+ Or, more concisely:
18
17
 
19
- Or install it yourself as:
18
+ $ gimp -t your-access-token -s gregbeech/test-1 -d gregbeech/test-2 --exclude-labels 'help wanted',question -i 23,47
20
19
 
21
- $ gem install gimp
20
+ You can set defaults for all command line options in a `.gimp` file, for example:
22
21
 
23
- ## Usage
22
+ ```yaml
23
+ token: your-access-token
24
+ source: gregbeech/test-1
25
+ destination: gregbeech/test-2
26
+ labels:
27
+ exclude:
28
+ - help wanted
29
+ - question
30
+ ```
31
+
32
+ Which lets you run the above command by just specifying the issue numbers; much handier if you're typically moving between the same two repos.
33
+
34
+ $ gimp -i 23,47
24
35
 
25
- TODO: Write usage instructions here
36
+ Remember to add an entry for `.gimp` to your `.gitignore` file so you don't commit your access token to the repo.
26
37
 
27
38
  ## Development
28
39
 
data/exe/gimp CHANGED
@@ -2,37 +2,50 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'gimp'
5
+ require 'yaml'
6
+ require 'hashie/mash'
5
7
 
6
- options = {}
7
- OptionParser.new do |opts|
8
+ options = Hashie::Mash.new(File.exist?('.gimp') ? YAML.load_file('.gimp') : {})
9
+ opts = OptionParser.new do |opts|
8
10
  opts.banner = 'Usage: gimp [options]'
9
11
 
12
+ opts.on('-t', '--token ACCESS_TOKEN', 'GitHub access token') do |access_token|
13
+ options.access_token = access_token
14
+ end
10
15
  opts.on('-s', '--source SOURCE', 'Source repository') do |source|
11
- options[:source] = source
16
+ options.source = source
12
17
  end
13
18
  opts.on('-d', '--destination DESTINATION', 'Destination repository') do |destination|
14
- options[:destination] = destination
19
+ options.destination = destination
15
20
  end
16
21
  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
22
+ options.issues = issues
21
23
  end
22
24
  opts.on('--exclude-labels [LABELS]', Array, 'Exclude labels', ' (exclude specific labels if LABELS supplied)') do |labels|
23
- options[:exclude_labels] = labels
25
+ options.labels ||= Hashie::Mash.new
26
+ options.labels.exclude = labels || true
24
27
  end
25
28
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
26
- options[:verbose] = v
29
+ options.verbose = v
27
30
  end
28
31
  opts.on_tail("-h", "--help", "Show this message") do
29
32
  puts opts
30
33
  exit
31
34
  end
32
- end.parse!
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
44
+ exit
45
+ end
33
46
 
34
47
  mover = Gimp::Mover.new(options)
35
- options[:issues].each do |id|
48
+ options.issues.each do |id|
36
49
  new_id = mover.move_issue(id)
37
- puts "#{options[:source]}##{id} -> #{options[:destination]}##{new_id}"
50
+ puts "#{options.source}##{id} -> #{options.destination}##{new_id}"
38
51
  end
@@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "octokit", "~> 4.1"
23
+ spec.add_dependency "hashie", "~> 3.4"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.10"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rspec", "~> 3.3"
27
28
  spec.add_development_dependency "gem-release"
28
29
  end
@@ -4,22 +4,22 @@ require "gimp/version"
4
4
  module Gimp
5
5
  class Mover
6
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] || []
7
+ @client = Octokit::Client.new(access_token: options.token)
8
+ @source = options.source
9
+ @destination = options.destination
10
+ @exclude_labels = options.labels.exclude if options.labels? && options.labels.exclude?
11
11
  @known_labels = Set.new
12
12
  end
13
13
 
14
14
  def move_issue(id)
15
15
  issue = @client.issue(@source, id)
16
- labels = @client.labels_for_issue(@source, id)
16
+ labels = filter_labels(@client.labels_for_issue(@source, id))
17
17
  comments = @client.issue_comments(@source, id)
18
18
 
19
19
  labels.each { |label| ensure_label(label) }
20
20
  new_issue = @client.create_issue(@destination, issue.title, issue.body,
21
21
  assignee: issue.assignee ? issue.assignee.login : nil,
22
- labels: labels.map(&:name) - @exclude_labels)
22
+ labels: labels.map(&:name))
23
23
  @client.add_comment(@destination, new_issue.number, "*Issue migrated from #{@source}##{issue.number}*")
24
24
  comments.each { |comment| @client.add_comment(@destination, new_issue.number, comment_text(comment)) }
25
25
 
@@ -29,8 +29,14 @@ module Gimp
29
29
 
30
30
  private
31
31
 
32
+ def filter_labels(labels)
33
+ return labels unless @exclude_labels
34
+ return [] if @exclude_labels == true
35
+ labels.reject { |label| @exclude_labels.include?(label.name) }
36
+ end
37
+
32
38
  def ensure_label(label)
33
- return if @exclude_labels.include?(label.name) || @known_labels.include?(label.name)
39
+ return if @known_labels.include?(label.name)
34
40
  @client.label(@destination, label.name)
35
41
  @known_labels << label.name
36
42
  rescue Octokit::NotFound
@@ -1,3 +1,3 @@
1
1
  module Gimp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Beech
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +70,16 @@ dependencies:
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '3.3'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: '3.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: gem-release
71
85
  requirement: !ruby/object:Gem::Requirement