geet 0.1.12 → 0.2.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +32 -6
  3. data/.rubocop_todo.yml +24 -1
  4. data/.travis.yml +7 -0
  5. data/Gemfile +3 -1
  6. data/Gemfile.lock +18 -0
  7. data/README.md +45 -11
  8. data/Rakefile +5 -0
  9. data/bin/geet +6 -9
  10. data/extra/issue_editing.png +0 -0
  11. data/extra/pr_editing.png +0 -0
  12. data/geet.gemspec +2 -2
  13. data/lib/geet/commandline/commands.rb +3 -1
  14. data/lib/geet/commandline/configuration.rb +37 -31
  15. data/lib/geet/commandline/editor.rb +66 -0
  16. data/lib/geet/git/repository.rb +5 -1
  17. data/lib/geet/github/abstract_issue.rb +7 -3
  18. data/lib/geet/github/api_interface.rb +9 -5
  19. data/lib/geet/github/branch.rb +15 -0
  20. data/lib/geet/github/gist.rb +1 -1
  21. data/lib/geet/github/issue.rb +1 -13
  22. data/lib/geet/github/label.rb +1 -1
  23. data/lib/geet/gitlab/api_interface.rb +9 -5
  24. data/lib/geet/helpers/os_helper.rb +8 -1
  25. data/lib/geet/resources/edit_summary_template.md +7 -0
  26. data/lib/geet/services/create_gist.rb +1 -1
  27. data/lib/geet/services/create_issue.rb +1 -1
  28. data/lib/geet/services/create_pr.rb +5 -2
  29. data/lib/geet/services/merge_pr.rb +8 -1
  30. data/lib/geet/version.rb +1 -1
  31. data/spec/integration/create_gist_spec.rb +5 -3
  32. data/spec/integration/create_issue_spec.rb +6 -3
  33. data/spec/integration/create_label_spec.rb +6 -4
  34. data/spec/integration/create_pr_spec.rb +4 -2
  35. data/spec/integration/list_issues_spec.rb +5 -3
  36. data/spec/integration/list_labels_spec.rb +4 -2
  37. data/spec/integration/list_milestones_spec.rb +3 -1
  38. data/spec/integration/list_prs_spec.rb +4 -2
  39. data/spec/integration/merge_pr_spec.rb +26 -1
  40. data/spec/spec_helper.rb +4 -2
  41. data/spec/vcr_cassettes/merge_pr_with_branch_deletion.yml +222 -0
  42. metadata +11 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc8920121911b4f4ce4fe3d0d090be3bef017587
4
- data.tar.gz: 5a85cb49ef2e87aef1fb930e314c83042b3b2abd
3
+ metadata.gz: 24a7f62fafb16b3920cb80f2f8d426cab3122fa6
4
+ data.tar.gz: 1ee1a9199b4ded572993b15b437efeb70cf9ab98
5
5
  SHA512:
6
- metadata.gz: d0a8ca5e66586a583c84e7113fef8e83e1e0897f9ab07f04bf0cf7cc4545d16f83ae43acbbef4e079255fd5233a3330b007d2a0e1b89fe85171f3075af260265
7
- data.tar.gz: 617080f5cce9ddd914aaca259f68aee020251b5157bf352dd736d24e27555c72d6a13527a8698a3ffe3c78d594e42e2ad7dbbdc8e3aae589d277b132dc9f9693
6
+ metadata.gz: 37a3767213474b09a881ce84074d3f48240870bfd404f8b12609f78153d41ab995630445dd9901cba750c50b307db5cd2c303f7b2c45c607cd12c4f8d5798e67
7
+ data.tar.gz: 4f8686315885d94a7aae287432b4b9d1c3b1afcbc0ffaa20d937b9d50538817602481546c968b6f797e0f8877860eb2f9cdb9cc89ac55b28c21eeee54b83e644
data/.rubocop.yml CHANGED
@@ -9,25 +9,48 @@ Layout/SpaceAroundOperators:
9
9
  Enabled: false
10
10
 
11
11
  Metrics/AbcSize:
12
- Max: 32
12
+ Exclude:
13
+ - 'bin/geet' # Program entry point switch/case
14
+
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'spec/**/*_spec.rb' # RSpec is styled in long blocks
18
+
19
+ Metrics/ClassLength:
20
+ Exclude:
21
+ - 'lib/geet/git/repository.rb'
22
+
23
+ Metrics/CyclomaticComplexity:
24
+ Exclude:
25
+ - 'lib/geet/github/api_interface.rb' # Switch-case (HTTP) parameter decoding
26
+ - 'lib/geet/gitlab/api_interface.rb' # Switch-case (HTTP) parameter decoding
27
+ - 'bin/geet' # Program entry point switch/case
13
28
 
14
29
  Metrics/LineLength:
15
- Max: 160
30
+ Max: 120
31
+ Exclude:
32
+ - 'lib/geet/git/repository.rb' # Table-style code
33
+ - 'lib/geet/commandline/configuration.rb' # Table-style code
16
34
 
17
35
  Metrics/MethodLength:
18
- Max: 29
36
+ Max: 20
37
+ Exclude:
38
+ - 'bin/geet' # Program entry point switch/case
39
+ - 'lib/geet/commandline/configuration.rb' # Table-style code
19
40
 
20
41
  Metrics/ParameterLists:
21
42
  CountKeywordArgs: false
22
43
 
23
44
  Metrics/PerceivedComplexity:
24
45
  Exclude:
25
- - 'lib/geet/services/create_issue.rb'
46
+ - 'lib/geet/services/create_issue.rb' # The creation method has many parameters
47
+ - 'lib/geet/services/create_pr.rb' # The creation method has many parameters
48
+ - 'bin/geet' # Program entry point switch/case
26
49
 
27
- Style/ConditionalAssignment:
50
+ Style/BlockComments:
28
51
  Enabled: false
29
52
 
30
- Style/Documentation:
53
+ Style/ConditionalAssignment:
31
54
  Enabled: false
32
55
 
33
56
  Style/DoubleNegation:
@@ -37,6 +60,9 @@ Style/GuardClause:
37
60
  Exclude:
38
61
  - 'lib/geet/git/repository.rb'
39
62
 
63
+ Style/IfUnlessModifier:
64
+ Enabled: false
65
+
40
66
  Style/NegatedIf:
41
67
  Enabled: false
42
68
 
data/.rubocop_todo.yml CHANGED
@@ -1,7 +1,30 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-11-06 20:05:36 +0100 using RuboCop version 0.51.0.
3
+ # on 2017-12-24 11:42:10 +0100 using RuboCop version 0.52.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: MaximumRangeSize.
11
+ Lint/MissingCopEnableDirective:
12
+ Exclude:
13
+ - 'lib/geet/commandline/configuration.rb'
14
+
15
+ # Offense count: 4
16
+ Metrics/AbcSize:
17
+ Max: 26
18
+
19
+ # Offense count: 2
20
+ Metrics/CyclomaticComplexity:
21
+ Max: 8
22
+
23
+ # Offense count: 2
24
+ # Configuration parameters: CountComments.
25
+ Metrics/MethodLength:
26
+ Max: 24
27
+
28
+ # Offense count: 27
29
+ Style/Documentation:
30
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3
4
+ - 2.4
5
+ # API tokens are always required, but not used in testing, since no requests are actually made.
6
+ env:
7
+ - GITHUB_API_TOKEN=phony GITLAB_API_TOKEN=phony
data/Gemfile CHANGED
@@ -8,10 +8,12 @@ gem 'simple_scripting', '~> 0.9.3'
8
8
 
9
9
  group :development, :test do
10
10
  gem 'byebug', '~> 9.1.0'
11
+ gem 'rake', '~> 12.3.0'
12
+ gem 'rubocop', '~> 0.52.0'
11
13
  end
12
14
 
13
15
  group :test do
16
+ gem 'rspec', '~> 3.7.0'
14
17
  gem 'vcr', '~> 3.0.3'
15
18
  gem 'webmock', '~> 3.1.1'
16
- gem 'rspec', '~> 3.7.0'
17
19
  end
data/Gemfile.lock CHANGED
@@ -3,13 +3,20 @@ GEM
3
3
  specs:
4
4
  addressable (2.5.2)
5
5
  public_suffix (>= 2.0.2, < 4.0)
6
+ ast (2.3.0)
6
7
  byebug (9.1.0)
7
8
  crack (0.4.3)
8
9
  safe_yaml (~> 1.0.0)
9
10
  diff-lcs (1.3)
10
11
  hashdiff (0.3.7)
12
+ parallel (1.12.1)
11
13
  parseconfig (1.0.8)
14
+ parser (2.4.0.2)
15
+ ast (~> 2.3)
16
+ powerpack (0.1.1)
12
17
  public_suffix (3.0.1)
18
+ rainbow (3.0.0)
19
+ rake (12.3.0)
13
20
  rspec (3.7.0)
14
21
  rspec-core (~> 3.7.0)
15
22
  rspec-expectations (~> 3.7.0)
@@ -23,9 +30,18 @@ GEM
23
30
  diff-lcs (>= 1.2.0, < 2.0)
24
31
  rspec-support (~> 3.7.0)
25
32
  rspec-support (3.7.0)
33
+ rubocop (0.52.0)
34
+ parallel (~> 1.10)
35
+ parser (>= 2.4.0.2, < 3.0)
36
+ powerpack (~> 0.1)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (~> 1.0, >= 1.0.1)
40
+ ruby-progressbar (1.9.0)
26
41
  safe_yaml (1.0.4)
27
42
  simple_scripting (0.9.3)
28
43
  parseconfig (~> 1.0)
44
+ unicode-display_width (1.3.0)
29
45
  vcr (3.0.3)
30
46
  webmock (3.1.1)
31
47
  addressable (>= 2.3.6)
@@ -37,7 +53,9 @@ PLATFORMS
37
53
 
38
54
  DEPENDENCIES
39
55
  byebug (~> 9.1.0)
56
+ rake (~> 12.3.0)
40
57
  rspec (~> 3.7.0)
58
+ rubocop (~> 0.52.0)
41
59
  simple_scripting (~> 0.9.3)
42
60
  vcr (~> 3.0.3)
43
61
  webmock (~> 3.1.1)
data/README.md CHANGED
@@ -1,20 +1,21 @@
1
+ [![Build Status][BS IMG]](https://travis-ci.org/saveriomiroddi/geet)
2
+
1
3
  # Geet
2
4
 
3
5
  Command line interface for performing Git hosting service operations.
4
6
 
5
- The current version supports only creating PRs/issues.
6
-
7
7
  This tool is very similar to [Hub](https://github.com/github/hub), but it supports a different set of operations, fully specified via command line.
8
8
 
9
9
  Please see the [development status](#development-status) section for informations about the current development.
10
10
 
11
- ## Providers support
11
+ ## Operation/providers support
12
12
 
13
13
  The functionalities currently supported are:
14
14
 
15
15
  - Github:
16
16
  - create gist
17
17
  - create issue
18
+ - create label
18
19
  - create PR
19
20
  - list issues
20
21
  - list labels
@@ -38,27 +39,37 @@ All the commands need to be run from the git repository.
38
39
 
39
40
  ### Create an issue (with label and assignees)
40
41
 
41
- Basic creation of an issue (after creation, will open the page in the browser):
42
+ Basic creation of an issue:
43
+
44
+ $ geet issue create
45
+
46
+ The default editor will be used for title/description:
42
47
 
43
- $ geet issue create 'Issue title' 'Multi
44
- > line
45
- > description'
48
+ ![Issue creation editing screenshot](/extra/issue_editing.png?raw=true)
46
49
 
47
50
  More advanced issue creation, with labels and assignees:
48
51
 
49
- $ geet issue create 'Issue title' 'Issue description' --label-patterns bug,wip --assignee-patterns john
52
+ $ geet issue create --label-patterns bug,wip --assignee-patterns john
50
53
 
51
54
  patterns are partial matches, so, for example, `johncarmack` will be matched as assignee in the first case.
52
55
 
56
+ After creation, the issue page will be automatically opened in the default browser.
57
+
53
58
  ### Create a PR (with label, reviewers, and assigned to self)
54
59
 
55
- Basic creation of a PR (after creation, will open the page in the browser):
60
+ Basic creation of a PR:
61
+
62
+ $ geet pr create
63
+
64
+ The default editor will be used for title/description:
56
65
 
57
- $ geet pr create 'PR title' 'Description'
66
+ ![Issue creation editing screenshot](/extra/pr_editing.png?raw=true)
58
67
 
59
68
  More advanced PR creation, with label and reviewers, assigned to self:
60
69
 
61
- $ geet pr create 'PR title' 'Closes #1' --label-patterns "code review" --reviewer-patterns kevin,tom,adrian
70
+ $ geet pr create --label-patterns "code review" --reviewer-patterns kevin,tom,adrian
71
+
72
+ After creation, the issue page will be automatically opened in the default browser.
62
73
 
63
74
  ### List issues/PRs
64
75
 
@@ -76,6 +87,27 @@ List the open PRs, in default order (inverse creation date):
76
87
  $ geet pr list
77
88
  > 21. Add PRs listing support (https://github.com/saveriomiroddi/geet/pull/21)
78
89
 
90
+ ### List milestones
91
+
92
+ $ geet milestone list
93
+ > 9. 0.2.0
94
+ > 4. Allow writing description in an editor (https://github.com/saveriomiroddi/geet/issues/4)
95
+ > 6. 0.2.1
96
+ > 69. Display warning when some operations are performed on a forked repository (https://github.com/saveriomiroddi/geet/issues/69)
97
+ > 60. Update Create PR test suite; the UTs are not inspecting some of the changes (https://github.com/saveriomiroddi/geet/issues/60)
98
+ > 51. Services should take repository in the initializer (https://github.com/saveriomiroddi/geet/issues/51)
99
+ > 7. 0.2.2
100
+ > 43. PR Merging: upstream support (https://github.com/saveriomiroddi/geet/issues/43)
101
+ > 35. Improve design of repository-independent actions (https://github.com/saveriomiroddi/geet/issues/35)
102
+
103
+ ### List labels
104
+
105
+ $ geet label list
106
+ > - bug (#ee0701)
107
+ > - enhancement (#84b6eb)
108
+ > - technical_debt (#ee0701)
109
+ > - top_priority (#d93f0b)
110
+
79
111
  ### Create a gist
80
112
 
81
113
  Create a private gist:
@@ -103,3 +135,5 @@ Examples:
103
135
  Geet is in alpha status. Although I use it daily, new features are frequently added, and internal/external APIs/workflows may change.
104
136
 
105
137
  The public release will be 1.0, and is expected to be released in February 2018 or earlier.
138
+
139
+ [BS img]: https://travis-ci.org/saveriomiroddi/geet.svg?branch=master
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task default: :spec
data/bin/geet CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative '../lib/geet/commandline/configuration.rb'
5
5
  require_relative '../lib/geet/commandline/commands.rb'
6
+ require_relative '../lib/geet/commandline/editor.rb'
6
7
  require_relative '../lib/geet/git/repository.rb'
7
8
  Dir[File.join(__dir__, '../lib/geet/services/*.rb')].each { |filename| require filename }
8
9
 
@@ -11,9 +12,7 @@ class GeetLauncher
11
12
  include Geet::Commandline::Commands
12
13
 
13
14
  def launch
14
- commandline_configuration = Commandline::Configuration.new
15
-
16
- command, options = commandline_configuration.decode_argv || exit
15
+ command, options = Commandline::Configuration.new.decode_argv || exit
17
16
 
18
17
  # `:upstream` is always false in the gist command case.
19
18
  repository = Git::Repository.new(upstream: !!options[:upstream])
@@ -25,7 +24,7 @@ class GeetLauncher
25
24
 
26
25
  Services::CreateGist.new.execute(repository, filename, options)
27
26
  when ISSUE_CREATE_COMMAND
28
- title, description = options.values_at(:title, :description)
27
+ title, description = Commandline::Editor.new.edit_summary
29
28
  options[:milestone_pattern] = options.delete(:milestone) if options.key?(:milestone)
30
29
 
31
30
  Services::CreateIssue.new.execute(repository, title, description, options)
@@ -40,20 +39,18 @@ class GeetLauncher
40
39
  when MILESTONE_LIST_COMMAND
41
40
  Services::ListMilestones.new.execute(repository)
42
41
  when PR_CREATE_COMMAND
43
- title, description = options.values_at(:title, :description)
42
+ title, description = Commandline::Editor.new.edit_summary
44
43
  options[:milestone_pattern] = options.delete(:milestone) if options.key?(:milestone)
45
44
 
46
45
  Services::CreatePr.new.execute(repository, title, description, options)
47
46
  when PR_LIST_COMMAND
48
47
  Services::ListPrs.new.execute(repository)
49
48
  when PR_MERGE_COMMAND
50
- Services::MergePr.new.execute(repository)
49
+ Services::MergePr.new.execute(repository, options)
51
50
  else
52
51
  raise "Internal error - Unrecognized command #{command.inspect}"
53
52
  end
54
53
  end
55
54
  end
56
55
 
57
- if __FILE__ == $0
58
- GeetLauncher.new.launch
59
- end
56
+ GeetLauncher.new.launch if $PROGRAM_NAME == __FILE__
Binary file
Binary file
data/geet.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
8
8
  s.name = 'geet'
9
9
  s.version = Geet::VERSION
10
10
  s.platform = Gem::Platform::RUBY
11
- s.required_ruby_version = '>= 2.2.0'
11
+ s.required_ruby_version = '>= 2.3.0'
12
12
  s.authors = ['Saverio Miroddi']
13
- s.date = '2017-12-23'
13
+ s.date = '2017-12-30'
14
14
  s.email = ['saverio.pub2@gmail.com']
15
15
  s.homepage = 'https://github.com/saveriomiroddi/geet'
16
16
  s.summary = 'Commandline interface for performing SCM (eg. GitHub) operations (eg. PR creation).'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Geet
2
4
  module Commandline
3
5
  module Commands
@@ -12,4 +14,4 @@ module Geet
12
14
  PR_MERGE_COMMAND = 'pr.merge'
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -17,15 +17,17 @@ module Geet
17
17
  '[description]'
18
18
  ].freeze
19
19
 
20
+ # SimpleScripting 0.9.3 doesn't allow frozen arrays when hash options are present.
21
+ #
22
+ # rubocop:disable Style/MutableConstant
20
23
  ISSUE_CREATE_OPTIONS = [
21
24
  ['-n', '--no-open-issue', "Don't open the issue link in the browser after creation"],
22
25
  ['-l', '--label-patterns "bug,help wanted"', 'Label patterns'],
23
26
  ['-m', '--milestone number_or_pattern', 'Milestone number or description pattern'],
24
27
  ['-a', '--assignee-patterns john,tom,adrian,kevin', 'Assignee login patterns. Defaults to authenticated user'],
25
28
  ['-u', '--upstream', 'Create on the upstream repository'],
26
- 'title',
27
- 'description'
28
- ].freeze
29
+ long_help: 'The default editor will be opened for editing title and description.'
30
+ ]
29
31
 
30
32
  LABEL_CREATE_OPTIONS = [
31
33
  ['-c', '--color color', '6-digits hex color; if not specified, a random one is created'],
@@ -36,11 +38,9 @@ module Geet
36
38
  ['-u', '--upstream', 'List on the upstream repository'],
37
39
  ].freeze
38
40
 
39
- LABEL_LIST_OPTIONS = [
40
- ].freeze
41
+ LABEL_LIST_OPTIONS = [].freeze
41
42
 
42
- MILESTONE_LIST_OPTIONS = [
43
- ].freeze
43
+ MILESTONE_LIST_OPTIONS = [].freeze
44
44
 
45
45
  PR_CREATE_OPTIONS = [
46
46
  ['-n', '--no-open-pr', "Don't open the PR link in the browser after creation"],
@@ -48,43 +48,49 @@ module Geet
48
48
  ['-m', '--milestone number_or_pattern', 'Milestone number or description pattern'],
49
49
  ['-r', '--reviewer-patterns john,tom,adrian,kevin', 'Reviewer login patterns'],
50
50
  ['-u', '--upstream', 'Create on the upstream repository'],
51
- 'title',
52
- 'description'
53
- ].freeze
51
+ long_help: 'The default editor will be opened for editing title and description.'
52
+ ]
54
53
 
55
54
  PR_LIST_OPTIONS = [
56
55
  ['-u', '--upstream', 'List on the upstream repository'],
57
56
  ].freeze
58
57
 
58
+ # SimpleScripting 0.9.3 doesn't allow frozen arrays when hash options are present.
59
+ #
59
60
  # rubocop:disable Style/MutableConstant
60
61
  PR_MERGE_OPTIONS = [
62
+ ['-d', '--delete-branch', 'Delete the branch after merging'],
61
63
  long_help: 'Merge the PR for the current branch'
62
64
  ]
63
65
 
66
+ # Commands decoding table
67
+
68
+ COMMANDS_DECODING_TABLE = {
69
+ 'gist' => {
70
+ 'create' => GIST_CREATE_OPTIONS,
71
+ },
72
+ 'issue' => {
73
+ 'create' => ISSUE_CREATE_OPTIONS,
74
+ 'list' => ISSUE_LIST_OPTIONS,
75
+ },
76
+ 'label' => {
77
+ 'create' => LABEL_CREATE_OPTIONS,
78
+ 'list' => LABEL_LIST_OPTIONS,
79
+ },
80
+ 'milestone' => {
81
+ 'list' => MILESTONE_LIST_OPTIONS,
82
+ },
83
+ 'pr' => {
84
+ 'create' => PR_CREATE_OPTIONS,
85
+ 'list' => PR_LIST_OPTIONS,
86
+ 'merge' => PR_MERGE_OPTIONS,
87
+ },
88
+ }
89
+
64
90
  # Public interface
65
91
 
66
92
  def decode_argv
67
- SimpleScripting::Argv.decode(
68
- 'gist' => {
69
- 'create' => GIST_CREATE_OPTIONS,
70
- },
71
- 'issue' => {
72
- 'create' => ISSUE_CREATE_OPTIONS,
73
- 'list' => ISSUE_LIST_OPTIONS,
74
- },
75
- 'label' => {
76
- 'create' => LABEL_CREATE_OPTIONS,
77
- 'list' => LABEL_LIST_OPTIONS,
78
- },
79
- 'milestone' => {
80
- 'list' => MILESTONE_LIST_OPTIONS,
81
- },
82
- 'pr' => {
83
- 'create' => PR_CREATE_OPTIONS,
84
- 'list' => PR_LIST_OPTIONS,
85
- 'merge' => PR_MERGE_OPTIONS,
86
- },
87
- )
93
+ SimpleScripting::Argv.decode(COMMANDS_DECODING_TABLE)
88
94
  end
89
95
  end
90
96
  end