story_branch 2.0.1 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +4 -6
- data/.story_branch.yml +2 -2
- data/Changelog.md +13 -0
- data/README.md +115 -61
- data/lib/story_branch/commands/configure.rb +2 -6
- data/lib/story_branch/config_manager.rb +4 -0
- data/lib/story_branch/constants.rb +17 -0
- data/lib/story_branch/issue_base.rb +21 -0
- data/lib/story_branch/linear_app/issue.rb +18 -0
- data/lib/story_branch/linear_app/team.rb +44 -0
- data/lib/story_branch/linear_app/tracker.rb +56 -0
- data/lib/story_branch/main.rb +11 -23
- data/lib/story_branch/tracker_initializer.rb +27 -0
- data/lib/story_branch/version.rb +1 -1
- data/story_branch.gemspec +3 -1
- metadata +51 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84fdb1c006fd2a93b1cc43521fbd68535235f04edc2d47aa983db3153bcf15a4
|
4
|
+
data.tar.gz: f8130e415f3b5463e37eeddf4078951a07003eaea3076fc97aa98b8ca5235c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b237f56136d2259ac96bea8f32ab310a385c4035483912f6bf11f8ca1168e53609d1af5692a5c9495f69246a87cf62f27884b1f5fade181f89220d0d1f5b9fd
|
7
|
+
data.tar.gz: cb2653af80af48f510c56aa6431168b5cf0a6320ee513364a8173e580f1e2e2110798dfa73bdc7fd2e5e31ce16b196201e208499a1c86e347b7dbbad0bd865ad
|
@@ -8,12 +8,10 @@ jobs:
|
|
8
8
|
runs-on: ubuntu-latest
|
9
9
|
|
10
10
|
steps:
|
11
|
-
- uses: actions/checkout@
|
12
|
-
- name: Set up Ruby 2.
|
13
|
-
uses:
|
14
|
-
with:
|
15
|
-
ruby-version: 2.6.x
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
- name: Set up Ruby 2.7
|
13
|
+
uses: ruby/setup-ruby@v1
|
16
14
|
- name: Rubocop Linter
|
17
|
-
uses: andrewmcodes/rubocop-linter-action@
|
15
|
+
uses: andrewmcodes/rubocop-linter-action@v3.3.0
|
18
16
|
env:
|
19
17
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.story_branch.yml
CHANGED
data/Changelog.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 2.2.0
|
2
|
+
|
3
|
+
Wed Aug 11 07:37:00 2022 +0800
|
4
|
+
|
5
|
+
- Add support for linear.app (#127)
|
6
|
+
- Adds dependency on story branch's graphql client
|
7
|
+
- Update README to match closer to current gem behavior
|
8
|
+
|
9
|
+
# 2.1.0
|
10
|
+
Wed Jul 20 18:30:00 2022 +0800
|
11
|
+
|
12
|
+
- Add configuration support to prepend branch name with a user prefix (#122)
|
13
|
+
|
1
14
|
# 0.3.3
|
2
15
|
Tue Jun 26 15:18:37 2018 +0800
|
3
16
|
|
data/README.md
CHANGED
@@ -2,10 +2,32 @@
|
|
2
2
|
[![CircleCI](https://circleci.com/gh/story-branch/story_branch/tree/master.svg?style=svg)](https://circleci.com/gh/story-branch/story_branch/tree/master)
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7dbd75908417656853d7/maintainability)](https://codeclimate.com/github/story-branch/story_branch/maintainability)
|
4
4
|
|
5
|
+
# Table of Contents
|
6
|
+
|
7
|
+
* [Installing](#installing)
|
8
|
+
* [Usage](#usage)
|
9
|
+
* [Commands available](#commands-available)
|
10
|
+
* [Commentary](#commentary)
|
11
|
+
* [Configuration](#configuration)
|
12
|
+
* [Configuring PivotalTracker](#configuring-pivotaltracker)
|
13
|
+
* [Configuring Github](#configuring-github)
|
14
|
+
* [Configuring JIRA](#configuring-jira)
|
15
|
+
* [Configuring LinearApp](#configuring-linearapp)
|
16
|
+
* [Available settings](#available-settings)
|
17
|
+
* [Issue placement](#issue-placement)
|
18
|
+
* [Branch username](#branch-username)
|
19
|
+
* [Finish tag](#finish-tag)
|
20
|
+
* [Creating a new branch following the naming convention](#creating-a-new-branch-following-the-naming-convention)
|
21
|
+
* [PivotalTracker specific commands](#pivotaltracker-specific-commands)
|
22
|
+
* [Migrating](#migrating)
|
23
|
+
* [Old configuration](#old-configuration)
|
24
|
+
* [Old commands](#old-commands)
|
25
|
+
* [Contributing](#contributing)
|
26
|
+
|
27
|
+
|
5
28
|
# Story Branch
|
6
29
|
|
7
|
-
Story branch is a CLI application that interacts with Pivotal Tracker, Github and
|
8
|
-
at the moment.
|
30
|
+
Story branch is a CLI application that interacts with Pivotal Tracker, Github, Jira and LinearApp.
|
9
31
|
|
10
32
|
For all the trackers it supports creating local branches from the tickets or
|
11
33
|
opening the ticket in your browser from the branch you're working on. In the future
|
@@ -46,25 +68,97 @@ Commands:
|
|
46
68
|
story_branch version # story_branch gem version
|
47
69
|
```
|
48
70
|
|
49
|
-
##
|
71
|
+
## Commentary
|
72
|
+
|
73
|
+
`story_branch configure`: Step by step configuration of a new tracker for your project
|
74
|
+
|
75
|
+
### Configuration
|
76
|
+
|
77
|
+
The configuration is split into two different files: a `.story_branch.yml` in the root folder
|
78
|
+
of the project where you're configuring the tool and a `.story_branch.yml` in user's home directory.
|
79
|
+
|
80
|
+
For the management of the home directory, story_branch relies on [XDG](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
|
81
|
+
specification, so if configured, it'll be installed under `~/.config` or whatever your machine
|
82
|
+
specifies.
|
83
|
+
|
84
|
+
The idea behind the two files is that the one in the root of the project should be committed to your
|
85
|
+
repository and defines basic tracker configuration settings to be shared across the contributors
|
86
|
+
to your repository. These configuration settings include the tracker type, project id in the tracker,
|
87
|
+
where you want the ticket number to be placed amongst others.
|
88
|
+
|
89
|
+
The file under your config directory is meant to be stored only locally as it will contain the api
|
90
|
+
keys needed for story branch to access your tracker. The story_branch file under your config directory
|
91
|
+
should not be published anywhere.
|
50
92
|
|
51
|
-
|
52
|
-
|
93
|
+
#### Configuring PivotalTracker
|
94
|
+
|
95
|
+
When running the command `story_branch configure` you'll be asked 3 things:
|
96
|
+
1. tracker - You should select Pivotal Tracker
|
97
|
+
2. project id - This can be fetched from the PivotalTracker url. E.g in the url `https://www.pivotaltracker.com/n/projects/651417`, the project id would be `651417`
|
98
|
+
3. api key - this is your personal api key. You can get that from [your profile page](https://www.pivotaltracker.com/profile)
|
99
|
+
|
100
|
+
#### Configuring Github
|
101
|
+
|
102
|
+
When running the command `story_branch configure` you'll be asked 3 things:
|
103
|
+
1. tracker - You should select Github
|
104
|
+
2. project id - This is the github repository name in the format `<owner>/<repo_name>`. E.g. `story-branch/story_branch`.
|
105
|
+
3. api key - this is your personal api token. You can create one under your [developer profile tokens page](https://github.com/settings/tokens)
|
106
|
+
|
107
|
+
#### Configuring JIRA
|
108
|
+
|
109
|
+
The configuration for JIRA is slightly more complex as the endpoint changes according
|
110
|
+
to your project setup. You will need an API token, which you can create a new one in your [JIRA id management page](https://id.atlassian.com/manage/api-tokens)
|
111
|
+
1. tracker - You should select JIRA
|
112
|
+
2. JIRA's subdomain - you should type the JIRA's subdomain that you use to access in your browser. E.g I'd type perxtechnologies to access to <https://perxtechnologies.atlassian.net>
|
113
|
+
3. JIRA's project key - this should match which project you want to fetch the issues from. E.g. PW is the key for my Project Whistler, so I'd type PW
|
114
|
+
4. API key that you should have gotten in the first description step
|
115
|
+
5. username used for login in the JIRA usually. If you use google email authentication, the username should be your email
|
116
|
+
|
117
|
+
#### Configuring LinearApp
|
118
|
+
|
119
|
+
When running the command `story_branch configure` you'll be asked 3 things:
|
120
|
+
1. tracker - You should select LinearApp
|
121
|
+
2. project id - This should be your team's id.
|
122
|
+
3. api key - this is your personal api token. You can create one under your [account API settings](https://linear.app/settings/api)
|
123
|
+
|
124
|
+
#### Available settings
|
125
|
+
|
126
|
+
##### Issue placement
|
127
|
+
|
128
|
+
On your local config you can add a line with `issue_placement: <Beginning|End>`.
|
129
|
+
Based on this configuration, when running `story_branch create`, the ticket id will be
|
130
|
+
used as prefix or suffix on the branch name.
|
131
|
+
|
132
|
+
E.g.
|
133
|
+
`issue_placement: Beginning`
|
53
134
|
|
54
|
-
|
135
|
+
`story_branch create` will create a branch in the format: `<issue_number>-<issue_title>`
|
55
136
|
|
56
|
-
|
57
|
-
This value will be stored in the local configuration file that will be committed
|
58
|
-
to the working repository
|
137
|
+
While
|
59
138
|
|
60
|
-
|
139
|
+
`issue_placement: End`
|
61
140
|
|
62
|
-
|
63
|
-
This value will be stored in your global configuration file that typically is
|
64
|
-
not shared with your co-workers in the repository. This way, each user will
|
65
|
-
be properly identified in the tracker
|
141
|
+
`story_branch create` will create a branch in the format: `<issue_title>-<issue_number>`
|
66
142
|
|
67
|
-
|
143
|
+
##### Branch username
|
144
|
+
|
145
|
+
In some cases your workflow requires you to have an identifier prefixing the branch name.
|
146
|
+
You can configure that by setting the configuration `branch_username` under your project's
|
147
|
+
name in the global `story_branch.yml` file (`defaults to: ~/.config/.story_branch.yml`)
|
148
|
+
|
149
|
+
E.g.
|
150
|
+
|
151
|
+
```
|
152
|
+
story-branch/story_branch:
|
153
|
+
api_key: my_fantastic_api_key
|
154
|
+
branch_username: rui
|
155
|
+
```
|
156
|
+
|
157
|
+
Doing so, when running `story_branch create`, it will create a branch in the format: `rui/<issue_number>-<issue_title>`
|
158
|
+
|
159
|
+
Naturally, the issue number will be placed based on the issue placement setting
|
160
|
+
|
161
|
+
##### Finish tag
|
68
162
|
|
69
163
|
On your local config you can add a line with `finish_tag: <Some random word>`.
|
70
164
|
This tag will be used in the commit message when running `story_branch finish`.
|
@@ -75,28 +169,11 @@ E.g.
|
|
75
169
|
`story_branch finish` will make a commit with the message
|
76
170
|
`[Resolves #12313] story title`
|
77
171
|
|
172
|
+
### Creating a new branch following the naming convention
|
78
173
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
your home folder (`~/`) and one in your project's root (`./`).
|
83
|
-
The one in your home folder will be used to store the different project's configurations
|
84
|
-
such as which api key to use. This is done so you don't need to commit your
|
85
|
-
api key to the repository but still be able to use different keys in case you
|
86
|
-
have different accounts.
|
87
|
-
|
88
|
-
The one in your project root will keep a reference to the project configuration.
|
89
|
-
For now, this reference is the project id. This file can be safely committed to
|
90
|
-
the repository and shared amongst your co-workers.
|
91
|
-
|
92
|
-
## Commentary
|
93
|
-
|
94
|
-
`story_branch create`: Creates a git branch with automatic reference to a
|
95
|
-
Pivotal Tracker Story. It will get started stories from your active
|
96
|
-
project. You can enter text and press TAB to search for a story
|
97
|
-
name, or TAB to show the full list. It will then suggest an editable
|
98
|
-
branch name. When the branch is created the `story_id` will
|
99
|
-
be appended to it.
|
174
|
+
`story_branch create`: Creates a git branch with automatic reference to a tracker ticket.
|
175
|
+
The tickets/stories that will be fetched will depend on the project type. Once you choose the
|
176
|
+
ticket to work on, a new branch will be created based on the ticket title and id.
|
100
177
|
|
101
178
|
e.g. `my-story-name-1234567`
|
102
179
|
|
@@ -107,6 +184,8 @@ e.g: `[Finishes #1234567] My story name`
|
|
107
184
|
You must stage all changes (or stash them) first. Note the commit will not
|
108
185
|
be pushed. Note: You'll be able to bail out of the commit.
|
109
186
|
|
187
|
+
### PivotalTracker specific commands
|
188
|
+
|
110
189
|
`story_branch start`: Start a story in Pivotal Tracker from the terminal.
|
111
190
|
It'll get all un-started stories in your current project. You can
|
112
191
|
enter text and press TAB to search for a story name, or TAB to show
|
@@ -117,31 +196,6 @@ It'll get all started stories in your current project. You can
|
|
117
196
|
enter text and press TAB to search for a story name, or TAB to show
|
118
197
|
the full list.
|
119
198
|
|
120
|
-
## Configuring PivotalTracker
|
121
|
-
|
122
|
-
When running the command `story_branch configure` you'll be asked 3 things:
|
123
|
-
1. tracker - You should select Pivotal Tracker
|
124
|
-
2. project id - This can be fetched from the PivotalTracker url. E.g in the url `https://www.pivotaltracker.com/n/projects/651417`, the project id would be `651417`
|
125
|
-
3. api key - this is your personal api key. You can get that from [your profile page](https://www.pivotaltracker.com/profile)
|
126
|
-
|
127
|
-
## Configuring Github
|
128
|
-
|
129
|
-
When running the command `story_branch configure` you'll be asked 3 things:
|
130
|
-
1. project id - This is the github repository name in the format `<owner>/<repo_name>`. E.g. `story-branch/story_branch`.
|
131
|
-
2. tracker - You should select Github
|
132
|
-
3. api key - this is your personal api token. You can create one under your
|
133
|
-
[developer profile tokens page](https://github.com/settings/tokens)
|
134
|
-
|
135
|
-
## Configuring JIRA
|
136
|
-
|
137
|
-
The configuration for JIRA is slightly more complex as the endpoint changes according
|
138
|
-
to your project setup. You will need an API token, which you can create a new one in your [JIRA id management page](https://id.atlassian.com/manage/api-tokens)
|
139
|
-
1. tracker - You should select JIRA
|
140
|
-
2. JIRA's subdomain - you should type the JIRA's subdomain that you use to access in your browser. E.g I'd type perxtechnologies to access to https://perxtechnologies.atlassian.net
|
141
|
-
3. JIRA's project key - this should match which project you want to fetch the issues from. E.g. PW is the key for my Project Whistler, so I'd type PW
|
142
|
-
4. API key that you should have gotten in the first description step
|
143
|
-
5. username used for login in the JIRA usually. If you use google email authentication, the username should be your email
|
144
|
-
|
145
199
|
## Migrating
|
146
200
|
|
147
201
|
### Old configuration
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../config_manager'
|
4
4
|
require_relative '../command'
|
5
|
+
require_relative '../constants'
|
5
6
|
require 'tty-config'
|
6
7
|
require 'tty-prompt'
|
7
8
|
|
@@ -73,12 +74,7 @@ module StoryBranch
|
|
73
74
|
def tracker
|
74
75
|
return @tracker if @tracker
|
75
76
|
|
76
|
-
|
77
|
-
'Pivotal Tracker' => 'pivotal-tracker',
|
78
|
-
'Github' => 'github',
|
79
|
-
'JIRA' => 'jira'
|
80
|
-
}
|
81
|
-
@tracker = prompt.select('Which tracker are you using?', trackers)
|
77
|
+
@tracker = prompt.select('Which tracker are you using?', StoryBranch::AVAILABLE_TRACKERS)
|
82
78
|
end
|
83
79
|
end
|
84
80
|
end
|
@@ -34,6 +34,10 @@ module StoryBranch
|
|
34
34
|
@issue_placement ||= @config.fetch(:issue_placement, default: 'End')
|
35
35
|
end
|
36
36
|
|
37
|
+
def branch_username
|
38
|
+
@branch_username ||= @config.fetch(project_key, :branch_username)
|
39
|
+
end
|
40
|
+
|
37
41
|
def finish_tag
|
38
42
|
@finish_tag ||= @config.fetch(project_key,
|
39
43
|
:finish_tag, default: 'Finishes')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StoryBranch
|
4
|
+
AVAILABLE_TRACKERS = {
|
5
|
+
'Pivotal Tracker' => 'pivotal-tracker',
|
6
|
+
'Github' => 'github',
|
7
|
+
'JIRA' => 'jira',
|
8
|
+
'LinearApp' => 'linearapp'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
TRACKERS_CLASSES = {
|
12
|
+
'pivotal-tracker' => 'StoryBranch::Pivotal::Tracker',
|
13
|
+
'github' => 'StoryBranch::Github::Tracker',
|
14
|
+
'jira' => 'StoryBranch::Jira::Tracker',
|
15
|
+
'linearapp' => 'StoryBranch::LinearApp::Tracker'
|
16
|
+
}.freeze
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StoryBranch
|
4
|
+
# Base class to represent an issue/ticket
|
5
|
+
class IssueBase
|
6
|
+
attr_reader :title, :id, :html_url
|
7
|
+
|
8
|
+
def initialize(tracker_issue, project = nil)
|
9
|
+
@project = project
|
10
|
+
@story = tracker_issue
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
"#{@id} - #{@title}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def dashed_title
|
18
|
+
StoryBranch::StringUtils.normalised_branch_name @title
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../issue_base'
|
4
|
+
|
5
|
+
module StoryBranch
|
6
|
+
module LinearApp
|
7
|
+
# LinearApp Issue representation
|
8
|
+
class Issue < StoryBranch::IssueBase
|
9
|
+
# NOTE: project here represents the team_id only
|
10
|
+
def initialize(tracker_issue, project)
|
11
|
+
super
|
12
|
+
@title = tracker_issue['title']
|
13
|
+
@id = "#{@project}-#{tracker_issue['number']}"
|
14
|
+
@html_url = tracker_issue['url']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'issue'
|
4
|
+
|
5
|
+
module StoryBranch
|
6
|
+
module LinearApp
|
7
|
+
# LinearApp groups tickets in teams, so this is the team representation in
|
8
|
+
# story branch. It's equivalent to a project
|
9
|
+
class Team
|
10
|
+
def initialize(team_id, client)
|
11
|
+
@team_id = team_id
|
12
|
+
@client = client
|
13
|
+
end
|
14
|
+
|
15
|
+
def stories(_options = {})
|
16
|
+
response = @client.get(graphql_query: graphql_query)
|
17
|
+
stories_json = response.data['viewer']['assignedIssues']['nodes']
|
18
|
+
stories_json.map { |story| Issue.new(story, @team_id) }
|
19
|
+
rescue StoryBranch::Graphql::Error => e
|
20
|
+
raise "Error while querying for tickets:\n#{e.message}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def graphql_query # rubocop:disable Metrics/MethodLength
|
26
|
+
%(
|
27
|
+
query Issue {
|
28
|
+
viewer {
|
29
|
+
assignedIssues (filter: { team: { key: { eq: "#{@team_id}"} } }) {
|
30
|
+
nodes {
|
31
|
+
id
|
32
|
+
title
|
33
|
+
description
|
34
|
+
number
|
35
|
+
url
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
).squeeze(' ')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'story_branch/graphql'
|
4
|
+
require_relative '../tracker_base'
|
5
|
+
require_relative 'team'
|
6
|
+
|
7
|
+
module StoryBranch
|
8
|
+
module LinearApp
|
9
|
+
# Linear App API wrapper for story branch tracker
|
10
|
+
class Tracker < StoryBranch::TrackerBase
|
11
|
+
API_URL = 'https://api.linear.app/'
|
12
|
+
|
13
|
+
def initialize(project_id:, api_key:, **)
|
14
|
+
super
|
15
|
+
|
16
|
+
# NOTE: project should be the representation of linear app team
|
17
|
+
@team_id = project_id
|
18
|
+
@api_key = api_key
|
19
|
+
@issue_regex = Regexp.new("#{@team_id}-(\\d+)")
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid?
|
23
|
+
!@api_key.nil? && !@team_id.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO: This should probably be renamed to something more meaningful
|
27
|
+
# in the sense that it should be workable stories/issues
|
28
|
+
# which depend on the tracker's workflow. PivotalTracker they need to
|
29
|
+
# be started and estimated, while for Github they just need to be open
|
30
|
+
def stories
|
31
|
+
project.stories
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_story_by_id(story_id)
|
35
|
+
project.stories(id: story_id).first
|
36
|
+
end
|
37
|
+
|
38
|
+
def client
|
39
|
+
@client ||= StoryBranch::Graphql::Client.new(api_url: API_URL, api_key: @api_key)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def configure_api
|
45
|
+
client
|
46
|
+
end
|
47
|
+
|
48
|
+
def project
|
49
|
+
return @project if @project
|
50
|
+
raise 'team must be set' unless @team_id
|
51
|
+
|
52
|
+
@project = Team.new(@team_id, client)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/story_branch/main.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './pivotal/tracker'
|
4
|
-
require_relative './github/tracker'
|
5
|
-
require_relative './jira/tracker'
|
6
3
|
require_relative './git_utils'
|
7
4
|
require_relative './git_wrapper'
|
8
5
|
require_relative './config_manager'
|
9
6
|
require_relative './url_opener'
|
7
|
+
require_relative 'tracker_initializer'
|
8
|
+
|
10
9
|
require 'tty-prompt'
|
11
10
|
|
12
11
|
module StoryBranch
|
@@ -20,7 +19,7 @@ module StoryBranch
|
|
20
19
|
def initialize
|
21
20
|
@config = ConfigManager.new
|
22
21
|
abort(@config.errors.join("\n")) unless @config.valid?
|
23
|
-
@tracker = initialize_tracker
|
22
|
+
@tracker = StoryBranch::TrackerInitializer.initialize_tracker(config: @config)
|
24
23
|
abort('Invalid tracker configuration setting.') unless @tracker.valid?
|
25
24
|
end
|
26
25
|
|
@@ -196,30 +195,19 @@ module StoryBranch
|
|
196
195
|
# rubocop:enable Metrics/MethodLength
|
197
196
|
|
198
197
|
def build_branch_name(branch_name, story_id)
|
199
|
-
if @config.issue_placement.casecmp('beginning').zero?
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
198
|
+
branch_name = if @config.issue_placement.casecmp('beginning').zero?
|
199
|
+
"#{story_id}-#{branch_name}"
|
200
|
+
else
|
201
|
+
"#{branch_name}-#{story_id}"
|
202
|
+
end
|
203
|
+
return branch_name unless @config.branch_username
|
204
|
+
|
205
|
+
"#{@config.branch_username}/#{branch_name}"
|
204
206
|
end
|
205
207
|
|
206
208
|
def current_branch
|
207
209
|
@current_branch ||= GitWrapper.current_branch
|
208
210
|
end
|
209
|
-
|
210
|
-
def initialize_tracker
|
211
|
-
# TODO: Ideally this would be mapped out somewhere so we don't need to
|
212
|
-
# evaluate anything from the config here
|
213
|
-
tracker_type = @config.tracker_type
|
214
|
-
case tracker_type
|
215
|
-
when 'github'
|
216
|
-
StoryBranch::Github::Tracker.new(**@config.tracker_params)
|
217
|
-
when 'pivotal-tracker'
|
218
|
-
StoryBranch::Pivotal::Tracker.new(**@config.tracker_params)
|
219
|
-
when 'jira'
|
220
|
-
StoryBranch::Jira::Tracker.new(**@config.tracker_params)
|
221
|
-
end
|
222
|
-
end
|
223
211
|
end
|
224
212
|
# rubocop:enable Metrics/ClassLength
|
225
213
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './constants'
|
4
|
+
require_relative './pivotal/tracker'
|
5
|
+
require_relative './github/tracker'
|
6
|
+
require_relative './jira/tracker'
|
7
|
+
require_relative './linear_app/tracker'
|
8
|
+
|
9
|
+
module StoryBranch
|
10
|
+
# helper class to find out which tracker should be initialized based on the
|
11
|
+
# configuration values
|
12
|
+
class TrackerInitializer
|
13
|
+
def self.initialize_tracker(config:)
|
14
|
+
tracker_class = find_tracker_class(config.tracker_type)
|
15
|
+
raise 'Invalid tracker configuration' unless tracker_class
|
16
|
+
|
17
|
+
tracker_class.new(**config.tracker_params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_tracker_class(tracker_type)
|
21
|
+
tracker_str = StoryBranch::TRACKERS_CLASSES[tracker_type]
|
22
|
+
return nil unless tracker_str
|
23
|
+
|
24
|
+
Kernel.const_get(tracker_str)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/story_branch/version.rb
CHANGED
data/story_branch.gemspec
CHANGED
@@ -55,7 +55,9 @@ Gem::Specification.new do |spec|
|
|
55
55
|
|
56
56
|
spec.add_runtime_dependency 'blanket_wrapper', '~> 3.0', '> 3.0'
|
57
57
|
spec.add_runtime_dependency 'damerau-levenshtein', '~> 1.3', '> 1.3'
|
58
|
+
spec.add_runtime_dependency 'httparty', '>0'
|
58
59
|
spec.add_runtime_dependency 'jira-ruby', '> 1.7', '< 3'
|
60
|
+
spec.add_runtime_dependency 'story_branch-graphql', '~> 0.0.2'
|
59
61
|
spec.add_runtime_dependency 'thor', '> 0.20', '< 2'
|
60
62
|
spec.add_runtime_dependency 'tty-command', '~> 0.8', '> 0.8'
|
61
63
|
spec.add_runtime_dependency 'tty-config', '~> 0.2', '> 0.2'
|
@@ -69,9 +71,9 @@ Gem::Specification.new do |spec|
|
|
69
71
|
spec.add_development_dependency 'ostruct', '~> 0.1', '> 0.1'
|
70
72
|
spec.add_development_dependency 'pry', '~> 0.11', '> 0.11'
|
71
73
|
spec.add_development_dependency 'rake', '>= 12.3.3', '< 14'
|
72
|
-
spec.add_development_dependency 'rubocop', '~> 1.22'
|
73
74
|
spec.add_development_dependency 'rspec', '~> 3', '> 3'
|
74
75
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4', '> 0.4'
|
76
|
+
spec.add_development_dependency 'rubocop', '~> 1.22'
|
75
77
|
spec.add_development_dependency 'simplecov', '~> 0.16', '> 0.16'
|
76
78
|
end
|
77
79
|
# rubocop:enable Metrics/BlockLength
|
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.
|
4
|
+
version: 2.2.1
|
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:
|
15
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: blanket_wrapper
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - ">"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '1.3'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: httparty
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: jira-ruby
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +88,20 @@ dependencies:
|
|
74
88
|
- - "<"
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '3'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: story_branch-graphql
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.0.2
|
98
|
+
type: :runtime
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.0.2
|
77
105
|
- !ruby/object:Gem::Dependency
|
78
106
|
name: thor
|
79
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -314,20 +342,6 @@ dependencies:
|
|
314
342
|
- - "<"
|
315
343
|
- !ruby/object:Gem::Version
|
316
344
|
version: '14'
|
317
|
-
- !ruby/object:Gem::Dependency
|
318
|
-
name: rubocop
|
319
|
-
requirement: !ruby/object:Gem::Requirement
|
320
|
-
requirements:
|
321
|
-
- - "~>"
|
322
|
-
- !ruby/object:Gem::Version
|
323
|
-
version: '1.22'
|
324
|
-
type: :development
|
325
|
-
prerelease: false
|
326
|
-
version_requirements: !ruby/object:Gem::Requirement
|
327
|
-
requirements:
|
328
|
-
- - "~>"
|
329
|
-
- !ruby/object:Gem::Version
|
330
|
-
version: '1.22'
|
331
345
|
- !ruby/object:Gem::Dependency
|
332
346
|
name: rspec
|
333
347
|
requirement: !ruby/object:Gem::Requirement
|
@@ -368,6 +382,20 @@ dependencies:
|
|
368
382
|
- - ">"
|
369
383
|
- !ruby/object:Gem::Version
|
370
384
|
version: '0.4'
|
385
|
+
- !ruby/object:Gem::Dependency
|
386
|
+
name: rubocop
|
387
|
+
requirement: !ruby/object:Gem::Requirement
|
388
|
+
requirements:
|
389
|
+
- - "~>"
|
390
|
+
- !ruby/object:Gem::Version
|
391
|
+
version: '1.22'
|
392
|
+
type: :development
|
393
|
+
prerelease: false
|
394
|
+
version_requirements: !ruby/object:Gem::Requirement
|
395
|
+
requirements:
|
396
|
+
- - "~>"
|
397
|
+
- !ruby/object:Gem::Version
|
398
|
+
version: '1.22'
|
371
399
|
- !ruby/object:Gem::Dependency
|
372
400
|
name: simplecov
|
373
401
|
requirement: !ruby/object:Gem::Requirement
|
@@ -441,6 +469,7 @@ files:
|
|
441
469
|
- lib/story_branch/commands/start.rb
|
442
470
|
- lib/story_branch/commands/unstart.rb
|
443
471
|
- lib/story_branch/config_manager.rb
|
472
|
+
- lib/story_branch/constants.rb
|
444
473
|
- lib/story_branch/git_utils.rb
|
445
474
|
- lib/story_branch/git_wrapper.rb
|
446
475
|
- lib/story_branch/github/issue.rb
|
@@ -448,9 +477,13 @@ files:
|
|
448
477
|
- lib/story_branch/github/milestone.rb
|
449
478
|
- lib/story_branch/github/project.rb
|
450
479
|
- lib/story_branch/github/tracker.rb
|
480
|
+
- lib/story_branch/issue_base.rb
|
451
481
|
- lib/story_branch/jira/issue.rb
|
452
482
|
- lib/story_branch/jira/project.rb
|
453
483
|
- lib/story_branch/jira/tracker.rb
|
484
|
+
- lib/story_branch/linear_app/issue.rb
|
485
|
+
- lib/story_branch/linear_app/team.rb
|
486
|
+
- lib/story_branch/linear_app/tracker.rb
|
454
487
|
- lib/story_branch/main.rb
|
455
488
|
- lib/story_branch/pivotal/project.rb
|
456
489
|
- lib/story_branch/pivotal/story.rb
|
@@ -466,6 +499,7 @@ files:
|
|
466
499
|
- lib/story_branch/templates/start/.gitkeep
|
467
500
|
- lib/story_branch/templates/unstart/.gitkeep
|
468
501
|
- lib/story_branch/tracker_base.rb
|
502
|
+
- lib/story_branch/tracker_initializer.rb
|
469
503
|
- lib/story_branch/url_opener.rb
|
470
504
|
- lib/story_branch/version.rb
|
471
505
|
- story_branch.gemspec
|
@@ -496,7 +530,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
496
530
|
- !ruby/object:Gem::Version
|
497
531
|
version: '0'
|
498
532
|
requirements: []
|
499
|
-
rubygems_version: 3.2.
|
533
|
+
rubygems_version: 3.2.32
|
500
534
|
signing_key:
|
501
535
|
specification_version: 4
|
502
536
|
summary: Create git branches based on your preferred tracker tickets
|