pivotoolz 1.2.2 → 1.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 +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +10 -2
- data/exe/post-slack-message +5 -10
- data/exe/pv-git-branch +3 -2
- data/lib/pivotoolz/git_branch.rb +20 -11
- data/lib/pivotoolz/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c0a93ab211a7ca9fdf96b3411b55af12aff671d8b9917b59c78d3ad32d39e76
|
4
|
+
data.tar.gz: 7e30198b5f17a1c9d07eb1c5cab65cee1b4ac36b2bb441a3301c3871f53d6258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8cebaeabffee302c4af7a1507aa755daada1fd7afe57bf4189574f3f40910e48cfa5aeda40297bed2f32f08e519fb2abbe4e38385838036ef5be3c6743a45de
|
7
|
+
data.tar.gz: 7ece7827562f290a8a67859a83370afa67fbb61c383ad7e77ed3700c91674003121f7c2b55bc45a4146d85800e3be5de40eb00952222af63d1c968f1a2170c18
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pivotoolz (
|
4
|
+
pivotoolz (1.3.0)
|
5
5
|
rest-client (~> 2.0.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.3)
|
11
|
-
domain_name (0.5.
|
11
|
+
domain_name (0.5.20190701)
|
12
12
|
unf (>= 0.0.5, < 1.0.0)
|
13
13
|
http-cookie (1.0.3)
|
14
14
|
domain_name (~> 0.5)
|
15
|
-
mime-types (3.
|
15
|
+
mime-types (3.3)
|
16
16
|
mime-types-data (~> 3.2015)
|
17
|
-
mime-types-data (3.
|
17
|
+
mime-types-data (3.2019.1009)
|
18
18
|
netrc (0.11.0)
|
19
19
|
rake (10.4.2)
|
20
20
|
rest-client (2.0.2)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
rspec-support (3.6.0)
|
37
37
|
unf (0.1.4)
|
38
38
|
unf_ext
|
39
|
-
unf_ext (0.0.7.
|
39
|
+
unf_ext (0.0.7.6)
|
40
40
|
|
41
41
|
PLATFORMS
|
42
42
|
ruby
|
@@ -48,4 +48,4 @@ DEPENDENCIES
|
|
48
48
|
rspec (~> 3.0)
|
49
49
|
|
50
50
|
BUNDLED WITH
|
51
|
-
1.
|
51
|
+
1.17.2
|
data/README.md
CHANGED
@@ -189,11 +189,19 @@ Be sure to set your `PIVOTAL_TRACKER_API_TOKEN` env variable in your `.bashrc` f
|
|
189
189
|
set your git config user initials like this: `git config --add user.initials af`. Otherwise it
|
190
190
|
will take your `git config user.name` or `whoami` information.
|
191
191
|
|
192
|
-
Example:
|
192
|
+
Example 1:
|
193
193
|
```bash
|
194
194
|
pv-git-branch "#111222333"
|
195
195
|
```
|
196
|
-
This would create and checkout a new branch:
|
196
|
+
This would create and checkout a new branch:
|
197
|
+
`af/features/building-someting-great-111222333`.
|
198
|
+
|
199
|
+
Example 2 (appending values):
|
200
|
+
```bash
|
201
|
+
pv-git-branch 12345678 version2 backend only
|
202
|
+
```
|
203
|
+
This would create and checkout a new branch:
|
204
|
+
`af/features/building-something-awesome-12345678-version2-backend-only`
|
197
205
|
|
198
206
|
If the branch had already been created, the command will automatically check out existing branch.
|
199
207
|
|
data/exe/post-slack-message
CHANGED
@@ -10,19 +10,14 @@ content = ARGV.empty? ? ARGF.read : StringIO.new(ARGV.join("\n")).read
|
|
10
10
|
exit 0 if content.strip.empty?
|
11
11
|
|
12
12
|
begin
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
text, *json = content.split("\n")
|
14
|
+
if !json.empty?
|
15
|
+
post_data = json.any? { |s| s.include? 'blocks' } ? JSON.parse(json.first) : {attachments: json.map { |j| JSON.parse(j) }}
|
16
16
|
begin
|
17
17
|
RestClient.post(
|
18
18
|
URL,
|
19
|
-
|
20
|
-
|
21
|
-
channel: channel,
|
22
|
-
text: content.split("\n")&.first || '',
|
23
|
-
attachments: attachments,
|
24
|
-
icon_emoji: ":ghost:"
|
25
|
-
}.to_json
|
19
|
+
post_data.merge({text: text || ''}).to_json,
|
20
|
+
{content_type: :json, accept: :json}
|
26
21
|
)
|
27
22
|
rescue RestClient::Exceptions => e
|
28
23
|
puts "Error posting to slack #{e.message}:\n#{e.backtrace}"
|
data/exe/pv-git-branch
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative '../lib/pivotoolz/git_branch'
|
4
4
|
|
5
|
-
if ARGV.length
|
5
|
+
if ARGV.length < 1
|
6
6
|
puts "#{GitBranch.usage_message}"
|
7
7
|
exit
|
8
8
|
end
|
9
|
-
|
9
|
+
first_arg, *the_rest = ARGV
|
10
|
+
puts GitBranch.new.generate(first_arg, the_rest)
|
data/lib/pivotoolz/git_branch.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
3
|
class GitBranch
|
4
|
-
def generate(story_id)
|
4
|
+
def generate(story_id, *append)
|
5
5
|
if !story_id
|
6
6
|
puts "#{GitBranch.usage_message}"
|
7
7
|
exit
|
@@ -13,8 +13,9 @@ class GitBranch
|
|
13
13
|
category = set_category(story['story_type'])
|
14
14
|
description = set_description(story['name'])
|
15
15
|
pivotal_id = story['id']
|
16
|
+
append = set_append_values(append)
|
16
17
|
|
17
|
-
create_branch("#{author}/#{category}/#{description}-#{pivotal_id}")
|
18
|
+
create_branch("#{author}/#{category}/#{description}-#{pivotal_id}#{append}")
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -38,9 +39,7 @@ class GitBranch
|
|
38
39
|
|
39
40
|
def set_author
|
40
41
|
author_name = get_author_initials || get_author_name || get_whoami || 'unknown'
|
41
|
-
author_name
|
42
|
-
author_name.tr!('.@!#$%^\&*()', '')
|
43
|
-
author_name.tr(' ', '+')
|
42
|
+
clean_text(author_name)
|
44
43
|
end
|
45
44
|
|
46
45
|
def get_author_initials
|
@@ -63,14 +62,24 @@ class GitBranch
|
|
63
62
|
end
|
64
63
|
|
65
64
|
def set_description(description)
|
66
|
-
description
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
clean_text(description)
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_append_values(appendings)
|
69
|
+
return '' if appendings.empty?
|
70
|
+
clean_appendings = appendings.map{|appending| clean_text(appending) }
|
71
|
+
"-#{clean_appendings.join('-')}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def clean_text(string_value)
|
75
|
+
string_value.tr!(':_,/.&!@#$%^*()[]\'`<>"', '') # remove unwanted punctuation
|
76
|
+
string_value.tr!('-', ' ') # replace dashes with space
|
77
|
+
string_value.downcase! # convert to lowercase
|
78
|
+
string_value.gsub!(/ +/,'-') # collapse spacing and replace spaces with dashes
|
79
|
+
string_value[0 .. 35].gsub(/-$/, '') # limit to 45 chars
|
71
80
|
end
|
72
81
|
|
73
82
|
def self.usage_message
|
74
|
-
"Usage : pv-git-branch '[
|
83
|
+
"Usage : pv-git-branch '<pivotal_story_id>' '[<appended_branchname_values>...]'"
|
75
84
|
end
|
76
85
|
end
|
data/lib/pivotoolz/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.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:
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -134,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.7.3
|
137
|
+
rubygems_version: 3.0.3
|
139
138
|
signing_key:
|
140
139
|
specification_version: 4
|
141
140
|
summary: Tools to save you time when working with Pivotal Tracker stories
|