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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee482afee960eb56b08d82ff6e1a99b5b7f07573
4
- data.tar.gz: 850fc5aa2badb4170ec98dc289d9e5a0b31449c4
3
+ metadata.gz: 7f72efc65285d87ffae7064cec06b0ad482114a7
4
+ data.tar.gz: b2a485f35a316a47f320123c67685bef40182c0f
5
5
  SHA512:
6
- metadata.gz: 812d018033aa466021c77d5136ad6f6abe1c6a63b5c96cce323d56382503f24c7e9397328c548b20b990ce67ff7ffc1f78ccfad55677562f0e96d3c2f800152a
7
- data.tar.gz: 30a77effaa6690f146a036c7b9396e8091f917136c8c4f62fa07eb0eeea682722f382cd31a92d87458673d92b577d66454e851cf3f47e7b422178ee5d8245130
6
+ metadata.gz: 49d1f4aa7e15914ca3bb705dd767e80064acd91fd3f76610ea82b5636638f6ab89fc9094835c212360e27788618758e84db2784a2466c856292fd89f528412c5
7
+ data.tar.gz: 14907bd1939a6b5bccc87e0ead36a39e781362e07edf8939091dc1d5df9f1e7d3cd1a2e29f389a2b1573c10482b92b232d11c0596ce301c92547a285709d2667
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.mov
data/Gemfile CHANGED
@@ -2,5 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- # Specify your gem's dependencies in pivotoolz.gemspec
6
5
  gemspec
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
- `bundle exec deliver-deployed-stories ENVIRONMENT`
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
- `bundle exec deliver-deployed-stories acceptance`
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
+ ![usage](assets/deliver-deployed-stories-demo.gif)
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
- `bundle exec get-story-info-from-id STORY_ID | bundle exec deliver-story`
85
+ `get-story-info-from-id STORY_ID | deliver-story`
64
86
  OR
65
- `bundle exec deliver-story '{"id": 123, "current_state": "finished"}'`
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
- ### `stories-deployed`
91
+ ### `story-ids-deployed`
92
+
93
+ Returns a newline delimited list of all story ids deployed
94
+ to the given environment.
70
95
 
71
- Returns a list of all stories deployed to a given environment.
96
+ Example:
97
+ ```
98
+ story-ids-deployed production
72
99
 
73
- Output is of the form:
100
+ # Output:
101
+ 123
102
+ 456
74
103
 
75
- STORY_TITLE:
76
- LINK_TO_STORY
104
+ ```
77
105
 
78
- STORY_TITLE:
79
- LINK_TO_STORY
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
+ ![usage](assets/merge-demo.gif)
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
+ ![usage](assets/tag-it-demo.gif)
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 stories-deployed production
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
+ ![usage](assets/stories-deployed-demo.gif)
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
- `bundle exec post-slack-message CHANNEL "MESSAGE_TEXT"`
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
- `{ echo Stories deployed to production:; bundle exec stories-deployed production; } | bundle exec post-slack-message '#production-deploys'`
174
+ ```bash
175
+ { echo Stories deployed to production:; stories-deployed production; } | post-slack-message '#production-deploys'
176
+ ```
111
177
 
112
- ### `story-ids-deployed`
178
+ `post-slack-message` can be helpful if you just want to have fun trolling your co-workers too.
113
179
 
114
- Returns a newline delimited list of all story ids deployed
115
- to the given environment.
180
+ ![usage](assets/post-slack-message-demo.gif)
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
- bundle exec story-ids-deployed production
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
+ ![usage](assets/pv-git-branch-demo.gif)
127
204
 
128
205
  ## Development
129
206
 
Binary file
Binary file
Binary file
Binary file
Binary file
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/exe/pv-git-branch ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/pivotoolz/git_branch'
4
+
5
+ if ARGV.length != 1
6
+ puts "#{GitBranch.usage_message}"
7
+ exit
8
+ end
9
+ puts GitBranch.new.generate(ARGV.first)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pivotoolz
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/pivotoolz.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "pivotoolz/version"
2
2
 
3
3
  module Pivotoolz
4
- # Your code goes here...
5
4
  end
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.1.3
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-03-05 00:00:00.000000000 Z
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