story_branch 2.2.1 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84fdb1c006fd2a93b1cc43521fbd68535235f04edc2d47aa983db3153bcf15a4
4
- data.tar.gz: f8130e415f3b5463e37eeddf4078951a07003eaea3076fc97aa98b8ca5235c46
3
+ metadata.gz: 1c822a7c84f60daf75722fad9e100028aa8bec4e28b6f0a811135c511975c756
4
+ data.tar.gz: b44a6fe6aa0a18f9bae8ff0c240f99637fea1c2b519bdc645449b867529f253d
5
5
  SHA512:
6
- metadata.gz: 1b237f56136d2259ac96bea8f32ab310a385c4035483912f6bf11f8ca1168e53609d1af5692a5c9495f69246a87cf62f27884b1f5fade181f89220d0d1f5b9fd
7
- data.tar.gz: cb2653af80af48f510c56aa6431168b5cf0a6320ee513364a8173e580f1e2e2110798dfa73bdc7fd2e5e31ce16b196201e208499a1c86e347b7dbbad0bd865ad
6
+ metadata.gz: 06c7c3802616972f40da61237b8f7f44bac809ec8b77f19ecddd700fef1b65c7551db9fe0cb31bc8e17935ad8b87d086828ce7fd398d50c02d7eac73f7ab9f70
7
+ data.tar.gz: 9c59ac43012d9bf73d680b5736897b2c6b7fea6d6c196f801c7df2718adb82aa81c719a28b1b9ba2b8658de2df512a89a920acc3cb402984fd8259c34a93efea
data/.circleci/config.yml CHANGED
@@ -7,7 +7,7 @@ workflows:
7
7
  - test:
8
8
  matrix:
9
9
  parameters:
10
- ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster", "ruby:3.0-buster"]
10
+ ruby_version: ["ruby:2.6", "ruby:2.7", "ruby:3.0"]
11
11
 
12
12
  filters:
13
13
  tags:
@@ -29,7 +29,7 @@ jobs:
29
29
  ruby_version:
30
30
  type: string
31
31
  docker:
32
- - image: circleci/<< parameters.ruby_version >>
32
+ - image: cimg/<< parameters.ruby_version >>
33
33
  working_directory: ~/repo
34
34
 
35
35
  steps:
@@ -45,6 +45,7 @@ jobs:
45
45
  - run:
46
46
  name: install dependencies
47
47
  command: |
48
+ rm Gemfile.lock
48
49
  gem install bundler
49
50
  bundle install --jobs=4 --retry=3 --path vendor/bundle
50
51
 
@@ -76,7 +77,7 @@ jobs:
76
77
 
77
78
  publish:
78
79
  docker:
79
- - image: circleci/ruby:3.0-buster
80
+ - image: cimg/ruby:3.0
80
81
  working_directory: ~/repo
81
82
 
82
83
  steps:
data/.gitignore CHANGED
@@ -4,4 +4,3 @@ story_branch-*.gem
4
4
  .byebug_history
5
5
  coverage
6
6
  tools/release*.*
7
- Gemfile.lock
data/Changelog.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 2.3.0
2
+
3
+ Mon Aug 22 23:55:00 2022 +0800
4
+
5
+ - Moved Git::Wrapper to separate gem
6
+ - Try to read local file from both current path and git root's directory (#136)
7
+
8
+ # 2.2.1
9
+
10
+ Mon Aug 15 17:36:00 2022 +0800
11
+
12
+ - Fixed broken command story_branch open when using linear.app (#126)
13
+ - Fixed linear.app graphql query to filter team by key instead of name (#130)
14
+
1
15
  # 2.2.0
2
16
 
3
17
  Wed Aug 11 07:37:00 2022 +0800
data/Gemfile.lock ADDED
@@ -0,0 +1,162 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ story_branch (2.3.0)
5
+ blanket_wrapper (~> 3.0, > 3.0)
6
+ damerau-levenshtein (~> 1.3, > 1.3)
7
+ httparty (> 0)
8
+ jira-ruby (> 1.7, < 3)
9
+ story_branch-git_wrapper (~> 0.0.3)
10
+ story_branch-graphql (~> 0.0.2)
11
+ thor (> 0.20, < 2)
12
+ tty-command (~> 0.8, > 0.8)
13
+ tty-config (~> 0.2, > 0.2)
14
+ tty-pager (~> 0.12, > 0.12)
15
+ tty-prompt (~> 0.18, > 0.18)
16
+ xdg (> 3.0, < 6)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ activesupport (7.0.3.1)
22
+ concurrent-ruby (~> 1.0, >= 1.0.2)
23
+ i18n (>= 1.6, < 2)
24
+ minitest (>= 5.1)
25
+ tzinfo (~> 2.0)
26
+ addressable (2.8.1)
27
+ public_suffix (>= 2.0.2, < 6.0)
28
+ ast (2.4.2)
29
+ atlassian-jwt (0.2.1)
30
+ jwt (~> 2.1)
31
+ blanket_wrapper (3.0.2)
32
+ httparty
33
+ recursive-open-struct
34
+ coderay (1.1.3)
35
+ concurrent-ruby (1.1.10)
36
+ damerau-levenshtein (1.3.3)
37
+ diff-lcs (1.5.0)
38
+ docile (1.4.0)
39
+ fakefs (1.8.0)
40
+ git (1.12.0)
41
+ addressable (~> 2.8)
42
+ rchardet (~> 1.8)
43
+ httparty (0.20.0)
44
+ mime-types (~> 3.0)
45
+ multi_xml (>= 0.5.2)
46
+ i18n (1.12.0)
47
+ concurrent-ruby (~> 1.0)
48
+ jira-ruby (2.2.0)
49
+ activesupport
50
+ atlassian-jwt
51
+ multipart-post
52
+ oauth (~> 0.5, >= 0.5.0)
53
+ json (2.6.2)
54
+ jwt (2.4.1)
55
+ method_source (1.0.0)
56
+ mime-types (3.4.1)
57
+ mime-types-data (~> 3.2015)
58
+ mime-types-data (3.2022.0105)
59
+ minitest (5.16.3)
60
+ multi_xml (0.6.0)
61
+ multipart-post (2.2.3)
62
+ oauth (0.5.10)
63
+ ostruct (0.5.5)
64
+ parallel (1.22.1)
65
+ parser (3.1.2.1)
66
+ ast (~> 2.4.1)
67
+ pastel (0.8.0)
68
+ tty-color (~> 0.5)
69
+ pry (0.14.1)
70
+ coderay (~> 1.1)
71
+ method_source (~> 1.0)
72
+ public_suffix (5.0.0)
73
+ rainbow (3.1.1)
74
+ rake (13.0.6)
75
+ rchardet (1.8.0)
76
+ recursive-open-struct (1.1.3)
77
+ regexp_parser (2.5.0)
78
+ rexml (3.2.5)
79
+ rspec (3.11.0)
80
+ rspec-core (~> 3.11.0)
81
+ rspec-expectations (~> 3.11.0)
82
+ rspec-mocks (~> 3.11.0)
83
+ rspec-core (3.11.0)
84
+ rspec-support (~> 3.11.0)
85
+ rspec-expectations (3.11.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.11.0)
88
+ rspec-mocks (3.11.1)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.11.0)
91
+ rspec-support (3.11.0)
92
+ rspec_junit_formatter (0.5.1)
93
+ rspec-core (>= 2, < 4, != 2.12.0)
94
+ rubocop (1.35.1)
95
+ json (~> 2.3)
96
+ parallel (~> 1.10)
97
+ parser (>= 3.1.2.1)
98
+ rainbow (>= 2.2.2, < 4.0)
99
+ regexp_parser (>= 1.8, < 3.0)
100
+ rexml (>= 3.2.5, < 4.0)
101
+ rubocop-ast (>= 1.20.1, < 2.0)
102
+ ruby-progressbar (~> 1.7)
103
+ unicode-display_width (>= 1.4.0, < 3.0)
104
+ rubocop-ast (1.21.0)
105
+ parser (>= 3.1.1.0)
106
+ ruby-progressbar (1.11.0)
107
+ simplecov (0.21.2)
108
+ docile (~> 1.1)
109
+ simplecov-html (~> 0.11)
110
+ simplecov_json_formatter (~> 0.1)
111
+ simplecov-html (0.12.3)
112
+ simplecov_json_formatter (0.1.4)
113
+ story_branch-git_wrapper (0.0.3)
114
+ story_branch-graphql (0.0.2)
115
+ httparty (> 0)
116
+ strings (0.2.1)
117
+ strings-ansi (~> 0.2)
118
+ unicode-display_width (>= 1.5, < 3.0)
119
+ unicode_utils (~> 1.4)
120
+ strings-ansi (0.2.0)
121
+ thor (1.2.1)
122
+ tty-color (0.6.0)
123
+ tty-command (0.10.1)
124
+ pastel (~> 0.8)
125
+ tty-config (0.6.0)
126
+ tty-cursor (0.7.1)
127
+ tty-pager (0.14.0)
128
+ strings (~> 0.2.0)
129
+ tty-screen (~> 0.8)
130
+ tty-prompt (0.23.1)
131
+ pastel (~> 0.8)
132
+ tty-reader (~> 0.8)
133
+ tty-reader (0.9.0)
134
+ tty-cursor (~> 0.7)
135
+ tty-screen (~> 0.8)
136
+ wisper (~> 2.0)
137
+ tty-screen (0.8.1)
138
+ tzinfo (2.0.5)
139
+ concurrent-ruby (~> 1.0)
140
+ unicode-display_width (2.2.0)
141
+ unicode_utils (1.4.0)
142
+ wisper (2.0.1)
143
+ xdg (4.5.0)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ bundler (~> 2.1, > 2.1)
150
+ fakefs (> 0.14, < 2)
151
+ git (~> 1.5, > 1.5)
152
+ ostruct (~> 0.1, > 0.1)
153
+ pry (~> 0.11, > 0.11)
154
+ rake (>= 12.3.3, < 14)
155
+ rspec (~> 3, > 3)
156
+ rspec_junit_formatter (~> 0.4, > 0.4)
157
+ rubocop (~> 1.22)
158
+ simplecov (~> 0.16, > 0.16)
159
+ story_branch!
160
+
161
+ BUNDLED WITH
162
+ 2.1.4
@@ -3,6 +3,7 @@
3
3
  require 'tty-config'
4
4
  require 'tty-prompt'
5
5
  require 'xdg'
6
+ require 'story_branch/git'
6
7
 
7
8
  module StoryBranch
8
9
  # Config manager is used to manage all possible configuration settings
@@ -141,7 +142,7 @@ module StoryBranch
141
142
  end
142
143
 
143
144
  def load_configs
144
- @local = read_config('.')
145
+ @local = local_config
145
146
  xdg_conf = XDG::Config.new
146
147
  home_path = if conf_exist?(Dir.home)
147
148
  Dir.home
@@ -151,6 +152,11 @@ module StoryBranch
151
152
  @global = read_config(home_path)
152
153
  end
153
154
 
155
+ def local_config
156
+ possible_local_paths = [Dir.pwd, StoryBranch::Git::Wrapper.command('rev-parse --show-toplevel')].uniq
157
+ read_config(possible_local_paths)
158
+ end
159
+
154
160
  def read_config(path)
155
161
  config = init_config(path)
156
162
  config.read if config.persisted?
@@ -162,10 +168,13 @@ module StoryBranch
162
168
  config.persisted?
163
169
  end
164
170
 
165
- def init_config(path)
171
+ def init_config(paths)
172
+ paths = Array(paths)
166
173
  config = ::TTY::Config.new
167
174
  config.filename = CONFIG_FILENAME
168
- config.append_path path
175
+ paths.each do |path|
176
+ config.append_path path
177
+ end
169
178
  config
170
179
  end
171
180
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'damerau-levenshtein'
4
- require_relative './git_wrapper'
4
+ require 'story_branch/git/wrapper'
5
5
 
6
6
  module StoryBranch
7
7
  # Class used to interact with git. It relies on git gem as the wrapper
8
8
  # and levenshtein algo to determine branch name proximity
9
9
  class GitUtils
10
10
  def self.similar_branch?(name)
11
- GitWrapper.branch_names.each do |n|
11
+ Git::Wrapper.branch_names.each do |n|
12
12
  return true if DamerauLevenshtein.distance(n, name) < 3
13
13
 
14
14
  branch_name_match = n.match(/(.*)(-[1-9]+[0-9]*$)/)
@@ -21,11 +21,11 @@ module StoryBranch
21
21
  end
22
22
 
23
23
  def self.branch_to_story_string(regex_matcher = /.*-(\d+$)/)
24
- GitWrapper.current_branch.match(regex_matcher)
24
+ Git::Wrapper.current_branch.match(regex_matcher)
25
25
  end
26
26
 
27
27
  def self.status?(state)
28
- status = GitWrapper.status
28
+ status = Git::Wrapper.status
29
29
  return false unless status
30
30
 
31
31
  !status[state].empty?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'story_branch/git/wrapper'
3
4
  require_relative './git_utils'
4
- require_relative './git_wrapper'
5
5
  require_relative './config_manager'
6
6
  require_relative './url_opener'
7
7
  require_relative 'tracker_initializer'
@@ -44,7 +44,7 @@ module StoryBranch
44
44
  commit_message = build_finish_message
45
45
  proceed = prompt.yes?("Commit with standard message? #{commit_message}")
46
46
  if proceed
47
- GitWrapper.commit commit_message
47
+ Git::Wrapper.commit commit_message
48
48
  else
49
49
  prompt.say 'Aborted'
50
50
  end
@@ -164,7 +164,7 @@ module StoryBranch
164
164
  feature_branch_name_with_story_id = build_branch_name(branch_name, story.id)
165
165
 
166
166
  prompt.say("Creating: #{feature_branch_name_with_story_id} with #{current_branch} as parent")
167
- GitWrapper.create_branch feature_branch_name_with_story_id
167
+ Git::Wrapper.create_branch feature_branch_name_with_story_id
168
168
  end
169
169
 
170
170
  def valid_branch_name(story)
@@ -206,7 +206,7 @@ module StoryBranch
206
206
  end
207
207
 
208
208
  def current_branch
209
- @current_branch ||= GitWrapper.current_branch
209
+ @current_branch ||= Git::Wrapper.current_branch
210
210
  end
211
211
  end
212
212
  # rubocop:enable Metrics/ClassLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoryBranch
4
- VERSION = '2.2.1'
4
+ VERSION = '2.3.0'
5
5
  end
data/story_branch.gemspec CHANGED
@@ -58,6 +58,7 @@ Gem::Specification.new do |spec|
58
58
  spec.add_runtime_dependency 'httparty', '>0'
59
59
  spec.add_runtime_dependency 'jira-ruby', '> 1.7', '< 3'
60
60
  spec.add_runtime_dependency 'story_branch-graphql', '~> 0.0.2'
61
+ spec.add_runtime_dependency 'story_branch-git_wrapper', '~> 0.0.3'
61
62
  spec.add_runtime_dependency 'thor', '> 0.20', '< 2'
62
63
  spec.add_runtime_dependency 'tty-command', '~> 0.8', '> 0.8'
63
64
  spec.add_runtime_dependency 'tty-config', '~> 0.2', '> 0.2'
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../lib/story_branch/git_wrapper'
3
+ require 'story_branch/git/wrapper'
4
4
 
5
5
  def grab_and_print_log(from, to)
6
- all_log = StoryBranch::GitWrapper.command("log #{from}..#{to}")
6
+ all_log = StoryBranch::Git::Wrapper.command("log #{from}..#{to}")
7
7
 
8
8
  matches = all_log.scan(/CHANGELOG\n(.*?)--- 8< ---/m).flatten
9
9
  matches.map!(&:strip)
@@ -19,7 +19,7 @@ end
19
19
  # rubocop:disable Metrics/MethodLength
20
20
  # rubocop:disable Metrics/AbcSize
21
21
  def print_all_logs
22
- all_tags = StoryBranch::GitWrapper.command_lines('tag --list')
22
+ all_tags = StoryBranch::Git::Wrapper.command_lines('tag --list')
23
23
  cleanup_tags = all_tags.map do |t|
24
24
  { cleanup_tag: t.delete('v'), tag: t }
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: story_branch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rui Baltazar
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2022-08-15 00:00:00.000000000 Z
15
+ date: 2022-08-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: blanket_wrapper
@@ -102,6 +102,20 @@ dependencies:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.0.2
105
+ - !ruby/object:Gem::Dependency
106
+ name: story_branch-git_wrapper
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.0.3
112
+ type: :runtime
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: 0.0.3
105
119
  - !ruby/object:Gem::Dependency
106
120
  name: thor
107
121
  requirement: !ruby/object:Gem::Requirement
@@ -448,6 +462,7 @@ files:
448
462
  - ".story_branch.yml"
449
463
  - Changelog.md
450
464
  - Gemfile
465
+ - Gemfile.lock
451
466
  - LICENSE.txt
452
467
  - README.md
453
468
  - Rakefile
@@ -471,7 +486,6 @@ files:
471
486
  - lib/story_branch/config_manager.rb
472
487
  - lib/story_branch/constants.rb
473
488
  - lib/story_branch/git_utils.rb
474
- - lib/story_branch/git_wrapper.rb
475
489
  - lib/story_branch/github/issue.rb
476
490
  - lib/story_branch/github/label.rb
477
491
  - lib/story_branch/github/milestone.rb
@@ -530,7 +544,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
530
544
  - !ruby/object:Gem::Version
531
545
  version: '0'
532
546
  requirements: []
533
- rubygems_version: 3.2.32
547
+ rubygems_version: 3.1.2
534
548
  signing_key:
535
549
  specification_version: 4
536
550
  summary: Create git branches based on your preferred tracker tickets
@@ -1,108 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # NOTE: Consider extracting this to a separate gem
4
- module StoryBranch
5
- # GitWrapper to help running git commands with direct system calls
6
- # Essentially it provides a couple of commands to interact with git
7
- # - StoryBranch::GitWrapper.command('<cmd>', [<opts>])
8
- # Returns the output as is
9
- #
10
- # - StoryBranch::GitWrapper.command_lines('<cmd>', [<opts>])
11
- # Returns the output split into an array of lines, stripped and chomped
12
- #
13
- # - StoryBranch::GitWrapper.branch_names
14
- # Returns the list of available branch names, locally and configured remotes
15
- class GitWrapper
16
- STATI_MATCHERS = {
17
- modified_rx: /^ M (.*)/,
18
- untracked_rx: /^\?\? (.*)/,
19
- staged_rx: /^M (.*)/,
20
- added_rx: /^A (.*)/
21
- }.freeze
22
-
23
- def self.command(cmd, opts = [])
24
- gw = new
25
- gw.call(cmd, opts)
26
- end
27
-
28
- def self.command_lines(cmd, opts = [])
29
- result = command(cmd, opts)
30
- lines = result.split("\n")
31
- lines.each(&:strip!)
32
- end
33
-
34
- def self.branch_names
35
- # NOTE: Regex matcher for cases as:
36
- # remotes/origin/allow.... <- remote branch (remove 'remotes/origin')
37
- # * allow.... <- * indicates current branch (remove '* ')
38
- # allow <- local branch (do nothing)
39
- regex = %r{(^remotes/.*/|\s|[*])}
40
- all_branches.map do |line|
41
- line = line.sub(regex, '')
42
- line
43
- end
44
- end
45
-
46
- def self.current_branch
47
- current_branch_line = all_branches.detect do |line|
48
- line.match(/\*/)
49
- end
50
- current_branch_line.tr('*', ' ').strip
51
- end
52
-
53
- def self.all_branches
54
- command_lines('branch', '-a')
55
- end
56
-
57
- def self.create_branch(name)
58
- command('checkout', ['-b', name])
59
- end
60
-
61
- def self.status
62
- g_status = command_lines('status', '-s')
63
- return nil if g_status.empty?
64
-
65
- {
66
- modified: status_collect(g_status, STATI_MATCHERS[:modified_rx]),
67
- untracked: status_collect(g_status, STATI_MATCHERS[:untracked_rx]),
68
- added: status_collect(g_status, STATI_MATCHERS[:added_rx]),
69
- staged: status_collect(g_status, STATI_MATCHERS[:staged_rx])
70
- }
71
- end
72
-
73
- def self.status_collect(status, regex)
74
- chosen_stati = status.select { |e| e.match(regex) }
75
- chosen_stati.map { |e| e.match(regex)[1] }
76
- end
77
-
78
- def self.commit(message)
79
- command('commit', ['-m', message])
80
- end
81
-
82
- def initialize
83
- @system_git = 'git'
84
- end
85
-
86
- def call(cmd, opts = [])
87
- opts = prepare_opts(opts)
88
- git_cmd = "#{@system_git} #{cmd} #{opts}"
89
- `#{git_cmd}`.chomp.strip
90
- end
91
-
92
- private
93
-
94
- # NOTE: Taken from ruby git gem
95
- def escape(str = '')
96
- str = str.to_s
97
- return "'#{str.gsub('\'', '\'"\'"\'')}'" if RUBY_PLATFORM !~ /mingw|mswin/
98
-
99
- # Keeping the old escape format for windows users
100
- escaped = str.gsub('\'', '\'\\\'\'')
101
- %("#{escaped}")
102
- end
103
-
104
- def prepare_opts(opts = [])
105
- [opts].flatten.map { |s| escape(s) }.join(' ')
106
- end
107
- end
108
- end