pivotoolz 0.1.3 → 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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +0 -1
- data/README.md +99 -22
- data/assets/deliver-deployed-stories-demo.gif +0 -0
- data/assets/merge-demo.gif +0 -0
- data/assets/post-slack-message-demo.gif +0 -0
- data/assets/pv-git-branch-demo.gif +0 -0
- data/assets/stories-deployed-demo.gif +0 -0
- data/assets/tag-it-demo.gif +0 -0
- data/bin/setup +0 -2
- data/exe/pv-git-branch +9 -0
- data/lib/pivotoolz/git_branch.rb +68 -0
- data/lib/pivotoolz/version.rb +1 -1
- data/lib/pivotoolz.rb +0 -1
- data/pivotoolz.gemspec +0 -2
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f72efc65285d87ffae7064cec06b0ad482114a7
|
4
|
+
data.tar.gz: b2a485f35a316a47f320123c67685bef40182c0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49d1f4aa7e15914ca3bb705dd767e80064acd91fd3f76610ea82b5636638f6ab89fc9094835c212360e27788618758e84db2784a2466c856292fd89f528412c5
|
7
|
+
data.tar.gz: 14907bd1939a6b5bccc87e0ead36a39e781362e07edf8939091dc1d5df9f1e7d3cd1a2e29f389a2b1573c10482b92b232d11c0596ce301c92547a285709d2667
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,23 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
$ gem install pivotoolz
|
29
29
|
|
30
|
+
To take full advantage of the tools, ensure you have the following
|
31
|
+
environment variables set:
|
32
|
+
```bash
|
33
|
+
PIVOTAL_TRACKER_API_TOKEN # Get this from your pivotal tracker account profile page
|
34
|
+
SLACK_WEBHOOK_URL # Get this by creating a new Incoming Webhook integration in Slack
|
35
|
+
```
|
36
|
+
|
37
|
+
Set the environment variables by either adding them to your `.bashrc` file
|
38
|
+
or exporting them prior to usage:
|
39
|
+
Set the environment variables by exporting them with the following commands:
|
40
|
+
`export PIVOTAL_TRACKER_API_TOKEN=YOUR_TOKEN`
|
41
|
+
`export SLACK_WEBHOOK_URL=YOUR_WEBHOOK_URL`
|
42
|
+
|
43
|
+
Alternatively, you can simply add those export statements to your `.bashrc` file
|
44
|
+
so that you won't have to keep typing it every time you want to use
|
45
|
+
`post-slack-message` or `deliver-deployed-stories` and their ilk.
|
46
|
+
|
30
47
|
## Usage
|
31
48
|
|
32
49
|
Pivotoolz is a collection of tiny programs that can be used individually
|
@@ -39,7 +56,7 @@ Deliver all stories that have been deployed to the given
|
|
39
56
|
environment since the previous and last deployment.
|
40
57
|
|
41
58
|
Example:
|
42
|
-
`
|
59
|
+
`deliver-deployed-stories ENVIRONMENT`
|
43
60
|
|
44
61
|
Where `ENVIRONMENT` is the environment you consider to be where stories
|
45
62
|
can be accepted/rejected.
|
@@ -50,7 +67,12 @@ test out stories. As long as we label our deployed git SHAs with tags
|
|
50
67
|
(using `tag-it`), we can automatically deliver any finished stories
|
51
68
|
that went out in the last deployment by simply running the command:
|
52
69
|
|
53
|
-
`
|
70
|
+
`deliver-deployed-stories acceptance`
|
71
|
+
|
72
|
+
Add the command to your deployment process to have your stories automatically delivered
|
73
|
+
on a successful deployment.
|
74
|
+
|
75
|
+

|
54
76
|
|
55
77
|
### `deliver-story`
|
56
78
|
|
@@ -60,27 +82,65 @@ required are `id` and `current_state`
|
|
60
82
|
Typically used with output from `get-story-info-from-id` piped in.
|
61
83
|
|
62
84
|
Example:
|
63
|
-
`
|
85
|
+
`get-story-info-from-id STORY_ID | deliver-story`
|
64
86
|
OR
|
65
|
-
`
|
87
|
+
`deliver-story '{"id": 123, "current_state": "finished"}'`
|
66
88
|
|
67
89
|
If `current_state` is not `finished`, the story will not be delivered.
|
68
90
|
|
69
|
-
### `
|
91
|
+
### `story-ids-deployed`
|
92
|
+
|
93
|
+
Returns a newline delimited list of all story ids deployed
|
94
|
+
to the given environment.
|
70
95
|
|
71
|
-
|
96
|
+
Example:
|
97
|
+
```
|
98
|
+
story-ids-deployed production
|
72
99
|
|
73
|
-
Output
|
100
|
+
# Output:
|
101
|
+
123
|
102
|
+
456
|
74
103
|
|
75
|
-
|
76
|
-
LINK_TO_STORY
|
104
|
+
```
|
77
105
|
|
78
|
-
|
79
|
-
|
106
|
+
|
107
|
+
|
108
|
+
### `merge`
|
109
|
+
|
110
|
+
Tired of running multiple commands to merge your branch when all you
|
111
|
+
really want to do is 'just merge' your branch? Now you can!
|
112
|
+
Just run `merge TARGET_BRANCH` where target branch is the branch
|
113
|
+
you want to merge into. The `merge` program takes care of rebasing the
|
114
|
+
latest local and upstream changes from target branch into your branch,
|
115
|
+
pushing your rebased branch, and then merging with the `--no-ff` flag.
|
116
|
+
Life is short, the time saved adds up real fast!
|
117
|
+
|
118
|
+
Example:
|
119
|
+
When in a branch you want to merge, just run
|
120
|
+
`merge master` to merge it into the `master` branch. You will end up
|
121
|
+
with a clean git history and all commits in your branch will be bundled
|
122
|
+
nicely under a top-level merge commit.
|
123
|
+
|
124
|
+

|
125
|
+
|
126
|
+
### `tag-it`
|
127
|
+
|
128
|
+
Tag the current git HEAD with a given tag (usually environment you're about to deploy to).
|
129
|
+
|
130
|
+
Example:
|
131
|
+
`tag-it production` - Will tag the current git HEAD with `production/TIMESTAMP`
|
132
|
+
|
133
|
+

|
134
|
+
|
135
|
+
### `stories-deployed`
|
136
|
+
|
137
|
+
If you use `tag-it` to label your git SHAs for deployment, this will return a list
|
138
|
+
of all stories deployed between the previous and last deployments using the tags to
|
139
|
+
scan a commit range.
|
80
140
|
|
81
141
|
Example:
|
82
142
|
```
|
83
|
-
bundle exec
|
143
|
+
stories-deployed production # You may need to prepend bundle exec depending on your setup
|
84
144
|
# Output:
|
85
145
|
|
86
146
|
Update README:
|
@@ -91,6 +151,8 @@ https://www.pivotaltracker.com/story/show/456
|
|
91
151
|
|
92
152
|
```
|
93
153
|
|
154
|
+

|
155
|
+
|
94
156
|
Use with `post-slack-message` to post a message in a slack deployment channel
|
95
157
|
with the list of stories that just got deployed.
|
96
158
|
|
@@ -102,28 +164,43 @@ Once you have done so, copy your Webhook URL into
|
|
102
164
|
an environment variable `SLACK_WEBHOOK_URL`.
|
103
165
|
If the `SLACK_WEBHOOK_URL` has been defined correctly, you will
|
104
166
|
be able to post a message in slack to any channel as follows:
|
105
|
-
|
167
|
+
```bash
|
168
|
+
post-slack-message CHANNEL "MESSAGE_TEXT"
|
169
|
+
```
|
106
170
|
Where CHANNEL is of the form "#channel" or "@user".
|
107
171
|
|
108
172
|
You can also pipe a message to the `post-slack-message` program. For
|
109
173
|
example:
|
110
|
-
|
174
|
+
```bash
|
175
|
+
{ echo Stories deployed to production:; stories-deployed production; } | post-slack-message '#production-deploys'
|
176
|
+
```
|
111
177
|
|
112
|
-
|
178
|
+
`post-slack-message` can be helpful if you just want to have fun trolling your co-workers too.
|
113
179
|
|
114
|
-
|
115
|
-
|
180
|
+

|
181
|
+
|
182
|
+
### `pv-git-branch`
|
183
|
+
|
184
|
+
Wouldn't it be nice to have all your Git branch names consistent with your dev team? Well now
|
185
|
+
you can with `pv-git-branch`. Just pass `pv-git-branch` a Pivotal Story ID, and it will return
|
186
|
+
branch name for you based on author name, the pivital story category, the pivotal story
|
187
|
+
name and the pivotal story id. Be sure to set your `PIVOTAL_TRACKER_API_TOKEN` env variable is
|
188
|
+
exported in your `.bashrc` file. If you want to explicitly set your initials as the author name,
|
189
|
+
set your git config user initials like this: `git config --add user.initials af`. Otherwise it
|
190
|
+
will take your `git config user.name` or `whoami` information.
|
116
191
|
|
117
192
|
Example:
|
193
|
+
```bash
|
194
|
+
pv-git-branch 111222333
|
118
195
|
```
|
119
|
-
|
120
|
-
|
121
|
-
# Output:
|
122
|
-
123
|
123
|
-
456
|
196
|
+
This would return something like: `af/features/building-someting-greate-111222333`
|
124
197
|
|
198
|
+
So it can be used with git like this:
|
199
|
+
```bashr
|
200
|
+
git checkout -b $(pv-git-branch 111222333)
|
125
201
|
```
|
126
202
|
|
203
|
+

|
127
204
|
|
128
205
|
## Development
|
129
206
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/bin/setup
CHANGED
data/exe/pv-git-branch
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class GitBranch
|
4
|
+
def generate(story_id)
|
5
|
+
if !story_id
|
6
|
+
puts "#{GitBranch.usage_message}"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
story = get_pivotal_story(story_id)
|
11
|
+
|
12
|
+
author = set_author
|
13
|
+
category = set_category(story['story_type'])
|
14
|
+
description = set_description(story['name'])
|
15
|
+
pivotal_id = story['id']
|
16
|
+
|
17
|
+
"#{author}/#{category}/#{description}-#{pivotal_id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def get_pivotal_story(pivotal_id)
|
23
|
+
unless ENV['PIVOTAL_TRACKER_API_TOKEN']
|
24
|
+
puts "!: You need to set the 'PIVOTAL_TRACKER_API_TOKEN' environment variable"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
story = JSON.parse(`get-story-info-from-id #{pivotal_id.tr('#', '')}`)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_author
|
32
|
+
author_name = get_author_initials || get_author_name || get_whoami || 'unknown'
|
33
|
+
author_name.downcase!
|
34
|
+
author_name.tr!('.@!#$%^\&*()', '')
|
35
|
+
author_name.tr(' ', '+')
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_author_initials
|
39
|
+
initials = `git config user.initials`.strip
|
40
|
+
initials unless initials.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_author_name
|
44
|
+
name = `git config user.name`.strip
|
45
|
+
name unless name.empty?
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_whoami
|
49
|
+
you = `whoami`.strip
|
50
|
+
you unless you.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_category(category)
|
54
|
+
category + 's'
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_description(description)
|
58
|
+
description.tr!(':_,/.&!@#$%^*()[]\'`<>"', '') # remove unwanted punctuation
|
59
|
+
description.tr!('-', ' ') # replace dashes with space
|
60
|
+
description.downcase! # convert to lowercase
|
61
|
+
description.gsub!(/ +/,'-') # collapse spacing and replace spaces with dashes
|
62
|
+
description[0 .. 45].gsub(/-$/, '')
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.usage_message
|
66
|
+
"Usage : bin/git-branch-it [pivotal_story_id]"
|
67
|
+
end
|
68
|
+
end
|
data/lib/pivotoolz/version.rb
CHANGED
data/lib/pivotoolz.rb
CHANGED
data/pivotoolz.gemspec
CHANGED
@@ -14,8 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/sufyanadam/pivotoolz"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
17
|
if spec.respond_to?(:metadata)
|
20
18
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
19
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotoolz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sufyan Adam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -77,6 +77,7 @@ executables:
|
|
77
77
|
- get-story-info-from-id
|
78
78
|
- merge
|
79
79
|
- post-slack-message
|
80
|
+
- pv-git-branch
|
80
81
|
- stories-deployed
|
81
82
|
- story-ids-deployed
|
82
83
|
- tag-it
|
@@ -92,6 +93,12 @@ files:
|
|
92
93
|
- LICENSE.txt
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
96
|
+
- assets/deliver-deployed-stories-demo.gif
|
97
|
+
- assets/merge-demo.gif
|
98
|
+
- assets/post-slack-message-demo.gif
|
99
|
+
- assets/pv-git-branch-demo.gif
|
100
|
+
- assets/stories-deployed-demo.gif
|
101
|
+
- assets/tag-it-demo.gif
|
95
102
|
- bin/console
|
96
103
|
- bin/setup
|
97
104
|
- exe/deliver-deployed-stories
|
@@ -99,10 +106,12 @@ files:
|
|
99
106
|
- exe/get-story-info-from-id
|
100
107
|
- exe/merge
|
101
108
|
- exe/post-slack-message
|
109
|
+
- exe/pv-git-branch
|
102
110
|
- exe/stories-deployed
|
103
111
|
- exe/story-ids-deployed
|
104
112
|
- exe/tag-it
|
105
113
|
- lib/pivotoolz.rb
|
114
|
+
- lib/pivotoolz/git_branch.rb
|
106
115
|
- lib/pivotoolz/version.rb
|
107
116
|
- pivotoolz.gemspec
|
108
117
|
homepage: https://github.com/sufyanadam/pivotoolz
|