bpescatore-stash 0.3.2
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 +15 -0
- data/.document +5 -0
- data/Gemfile +22 -0
- data/LICENSE.txt +20 -0
- data/README.md +114 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/bin/stash +170 -0
- data/lib/atlassian/stash/git.rb +57 -0
- data/lib/atlassian/stash/pull_request.rb +153 -0
- data/lib/atlassian/stash/repo_info.rb +62 -0
- data/lib/atlassian/stash/version.rb +9 -0
- data/lib/atlassian/util/text_util.rb +31 -0
- data/lib/stash_cli.rb +3 -0
- data/test/helper.rb +29 -0
- data/test/test_stash-create-pull-request.rb +84 -0
- data/test/test_stash-git.rb +96 -0
- data/test/test_stash-repo-info.rb +91 -0
- data/test/test_text-util.rb +103 -0
- metadata +241 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
include Atlassian::Stash
|
4
|
+
include Atlassian::Stash::Git
|
5
|
+
|
6
|
+
class TestStashRepoInfo < Minitest::Test
|
7
|
+
|
8
|
+
context "Extract repository info" do
|
9
|
+
should "extract project key and repo slug from Stash remote" do
|
10
|
+
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin https://sruiz@stash-dev.atlassian.com/scm/STASH/stash.git (push)")
|
11
|
+
|
12
|
+
ri = RepoInfo.create({})
|
13
|
+
assert_equal 'STASH', ri.projectKey
|
14
|
+
assert_equal 'stash', ri.slug
|
15
|
+
end
|
16
|
+
|
17
|
+
should "extracting project key and repo slug from non stash url raises exception" do
|
18
|
+
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin git@bitbucket.org:sebr/atlassian-stash-rubygem.git (push)")
|
19
|
+
assert_raises(RuntimeError) { RepoInfo.create({}) }
|
20
|
+
end
|
21
|
+
|
22
|
+
should "repo with hyphes" do
|
23
|
+
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin https://sruiz@stash-dev.atlassian.com/scm/s745h/stash-repository.git (push)")
|
24
|
+
ri = RepoInfo.create({})
|
25
|
+
assert_equal 's745h', ri.projectKey
|
26
|
+
assert_equal 'stash-repository', ri.slug
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "Create repo url" do
|
31
|
+
setup do
|
32
|
+
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin https://sruiz@stash-dev.atlassian.com/scm/STASH/stash.git (push)")
|
33
|
+
end
|
34
|
+
|
35
|
+
should "create expected repo path" do
|
36
|
+
config = {
|
37
|
+
'stash_url' => 'https://www.stash.com'
|
38
|
+
}
|
39
|
+
ri = RepoInfo.create config
|
40
|
+
assert_equal '/projects/STASH/repos/stash', ri.repoPath
|
41
|
+
end
|
42
|
+
|
43
|
+
should "create expected repo path with context" do
|
44
|
+
config = {
|
45
|
+
'stash_url' => 'https://www.stash.com/foo'
|
46
|
+
}
|
47
|
+
ri = RepoInfo.create config
|
48
|
+
assert_equal '/foo/projects/STASH/repos/stash', ri.repoPath
|
49
|
+
end
|
50
|
+
|
51
|
+
should "create expected repo path with context and query" do
|
52
|
+
config = {
|
53
|
+
'stash_url' => 'https://www.stash.com/foo'
|
54
|
+
}
|
55
|
+
ri = RepoInfo.create config
|
56
|
+
assert_equal '/foo/projects/STASH/repos/stash', ri.repoPath
|
57
|
+
end
|
58
|
+
|
59
|
+
should "create expected repo url with no suffix or branch" do
|
60
|
+
config = {
|
61
|
+
'stash_url' => 'https://www.stash.com'
|
62
|
+
}
|
63
|
+
ri = RepoInfo.create config
|
64
|
+
assert_equal 'https://www.stash.com/projects/STASH/repos/stash', ri.repoUrl(nil, nil)
|
65
|
+
end
|
66
|
+
|
67
|
+
should "create expected repo url with context" do
|
68
|
+
config = {
|
69
|
+
'stash_url' => 'https://www.stash.com/foo'
|
70
|
+
}
|
71
|
+
ri = RepoInfo.create config
|
72
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash', ri.repoUrl(nil, nil)
|
73
|
+
end
|
74
|
+
|
75
|
+
should "create expected repo url with path and branch" do
|
76
|
+
config = {
|
77
|
+
'stash_url' => 'https://www.stash.com/foo'
|
78
|
+
}
|
79
|
+
ri = RepoInfo.create config
|
80
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/commits?at=develop', ri.repoUrl('commits', 'develop')
|
81
|
+
end
|
82
|
+
|
83
|
+
should "create expected repo url with context, query, path and branch" do
|
84
|
+
config = {
|
85
|
+
'stash_url' => 'https://www.stash.com/foo?git=ftw'
|
86
|
+
}
|
87
|
+
ri = RepoInfo.create config
|
88
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/commits?git=ftw&at=develop', ri.repoUrl('commits', 'develop')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
include Atlassian::Util::TextUtil
|
3
|
+
|
4
|
+
class TextUtilTest < Minitest::Test
|
5
|
+
|
6
|
+
context "to_sentence_case" do
|
7
|
+
should "work with an empty string" do
|
8
|
+
assert_equal "", to_sentence_case("")
|
9
|
+
end
|
10
|
+
|
11
|
+
should "work with a single letter" do
|
12
|
+
assert_equal "A", to_sentence_case("a")
|
13
|
+
end
|
14
|
+
|
15
|
+
should "work with a single number" do
|
16
|
+
assert_equal "1", to_sentence_case("1")
|
17
|
+
end
|
18
|
+
|
19
|
+
should "work with multichar" do
|
20
|
+
assert_equal "Abc def", to_sentence_case("abc def")
|
21
|
+
end
|
22
|
+
|
23
|
+
should "coerce boolean false" do
|
24
|
+
assert_equal "False", to_sentence_case(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "coerce boolean true" do
|
28
|
+
assert_equal "True", to_sentence_case(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "coerce nil" do
|
32
|
+
assert_equal "", to_sentence_case(nil)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "coerce 0" do
|
36
|
+
assert_equal "0", to_sentence_case(0)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "coerce 1" do
|
40
|
+
assert_equal "1", to_sentence_case(1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "convert_branch_name_to_sentence" do
|
45
|
+
|
46
|
+
should "work with branch name with leading issue key" do
|
47
|
+
assert_equal "STASHDEV-1234 branch name", convert_branch_name_to_sentence("STASHDEV-1234-branch-name")
|
48
|
+
end
|
49
|
+
|
50
|
+
should "work with branch name with trailing issue key" do
|
51
|
+
assert_equal "Branch name STASHDEV-1234", convert_branch_name_to_sentence("branch-name-STASHDEV-1234")
|
52
|
+
end
|
53
|
+
|
54
|
+
should "work with branch name with issue key in middle" do
|
55
|
+
assert_equal "Branch STASHDEV-1234 name", convert_branch_name_to_sentence("branch-STASHDEV-1234-name")
|
56
|
+
end
|
57
|
+
|
58
|
+
should "work with branch name with multiple adjacent issue keys" do
|
59
|
+
assert_equal "Branch name STASHDEV-1234 STASHDEV-1234", convert_branch_name_to_sentence("branch-name-STASHDEV-1234-STASHDEV-1234")
|
60
|
+
end
|
61
|
+
|
62
|
+
should "work with branch name with no issue keys" do
|
63
|
+
assert_equal "Tests branch name", convert_branch_name_to_sentence("tests-branch-name")
|
64
|
+
end
|
65
|
+
|
66
|
+
should "work with branch name with underscore delimiter" do
|
67
|
+
assert_equal "Tests branch name", convert_branch_name_to_sentence("tests_branch_name")
|
68
|
+
end
|
69
|
+
|
70
|
+
should "work with branch name with mixed delimiter" do
|
71
|
+
assert_equal "Tests branch name", convert_branch_name_to_sentence("tests-branch_name")
|
72
|
+
end
|
73
|
+
|
74
|
+
should "work with single word branch name" do
|
75
|
+
assert_equal "Branchname", convert_branch_name_to_sentence("branchname")
|
76
|
+
end
|
77
|
+
|
78
|
+
should "work with slash delimited branch name" do
|
79
|
+
assert_equal "Feature/tests/STASHDEV-1234 branch name", convert_branch_name_to_sentence("feature/tests/STASHDEV-1234-branch-name")
|
80
|
+
end
|
81
|
+
|
82
|
+
should "work with slash delimited branch name with issue key component" do
|
83
|
+
assert_equal "Feature/STASHDEV-1234/branch name", convert_branch_name_to_sentence("feature/STASHDEV-1234/branch-name")
|
84
|
+
end
|
85
|
+
|
86
|
+
should "work with branch name with invalid issue key (punctuation)" do
|
87
|
+
assert_equal "STASHDEV! 1234 branch name", convert_branch_name_to_sentence("STASHDEV!-1234-branch-name")
|
88
|
+
end
|
89
|
+
|
90
|
+
should "work with branch name with invalid issue key (lowercase)" do
|
91
|
+
assert_equal "Stashdev 1234 branch name", convert_branch_name_to_sentence("stashdev-1234-branch-name")
|
92
|
+
end
|
93
|
+
|
94
|
+
should "work with branch name with invalid issue key (numbers in project key)" do
|
95
|
+
assert_equal "STASHDEV1 1234 branch name", convert_branch_name_to_sentence("STASHDEV1-1234-branch-name")
|
96
|
+
end
|
97
|
+
|
98
|
+
should "work with empty branch name" do
|
99
|
+
assert_equal "", convert_branch_name_to_sentence("")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bpescatore-stash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seb Ruiz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: !binary |-
|
20
|
+
MS4yLjU=
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: !binary |-
|
28
|
+
MS4yLjU=
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: json
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: !binary |-
|
36
|
+
MS43LjU=
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: !binary |-
|
44
|
+
MS43LjU=
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: commander
|
47
|
+
requirement: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: !binary |-
|
52
|
+
NC4xLjI=
|
53
|
+
type: :runtime
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: !binary |-
|
60
|
+
NC4xLjI=
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: launchy
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.4.2
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.4.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: shoulda
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rdoc
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: !binary |-
|
96
|
+
My4xMg==
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: !binary |-
|
104
|
+
My4xMg==
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: bundler
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.2.0
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.2.0
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: jeweler
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 2.0.0
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ~>
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.0.0
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: rcov
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: simplecov
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: minitest
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: mocha
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ! '>='
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
description: Provides convenient functions for interacting with Atlassian Stash through
|
190
|
+
the command line
|
191
|
+
email: bpescatore@mocana.com
|
192
|
+
executables:
|
193
|
+
- stash
|
194
|
+
extensions: []
|
195
|
+
extra_rdoc_files:
|
196
|
+
- LICENSE.txt
|
197
|
+
- README.md
|
198
|
+
files:
|
199
|
+
- .document
|
200
|
+
- Gemfile
|
201
|
+
- LICENSE.txt
|
202
|
+
- README.md
|
203
|
+
- Rakefile
|
204
|
+
- VERSION
|
205
|
+
- bin/stash
|
206
|
+
- lib/atlassian/stash/git.rb
|
207
|
+
- lib/atlassian/stash/pull_request.rb
|
208
|
+
- lib/atlassian/stash/repo_info.rb
|
209
|
+
- lib/atlassian/stash/version.rb
|
210
|
+
- lib/atlassian/util/text_util.rb
|
211
|
+
- lib/stash_cli.rb
|
212
|
+
- test/helper.rb
|
213
|
+
- test/test_stash-create-pull-request.rb
|
214
|
+
- test/test_stash-git.rb
|
215
|
+
- test/test_stash-repo-info.rb
|
216
|
+
- test/test_text-util.rb
|
217
|
+
homepage: https://bitbucket.org/atlassian/stash-command-line-tools
|
218
|
+
licenses:
|
219
|
+
- MIT
|
220
|
+
metadata: {}
|
221
|
+
post_install_message:
|
222
|
+
rdoc_options: []
|
223
|
+
require_paths:
|
224
|
+
- lib
|
225
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
|
+
requirements:
|
232
|
+
- - ! '>='
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
235
|
+
requirements: []
|
236
|
+
rubyforge_project:
|
237
|
+
rubygems_version: 2.4.2
|
238
|
+
signing_key:
|
239
|
+
specification_version: 4
|
240
|
+
summary: Command line tools for Atlassian Stash
|
241
|
+
test_files: []
|