atlassian-stash 0.6.1 → 0.7.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/README.md +12 -12
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/stash +27 -19
- data/lib/atlassian/stash/repo_info.rb +18 -4
- data/test/test_stash-repo-info.rb +76 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 004918119e117aac4f9359f4820c9b81c5adfa82
|
4
|
+
data.tar.gz: f6fc3a770ad9348126ff3ce781292218f7dd564a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9be92ea03f9de591a0d49aa7f2d160eb3557586b6ea2d8bf6cd047e0769941dd7fe408ddd496332bdd5b2984bcf0dcf089c8b202d17a68450290adac5645e2d2
|
7
|
+
data.tar.gz: 590e8c86f39160ab38e402a7f5ddeb61ec0fdee929aca5929d6cf1aac13c343c63b004355959615d3bd240031f12284beb38dcd8829a63b4687011ac0ac9708a
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# Bitbucket Server Command Line Tools
|
2
2
|
|
3
3
|
[ ](https://codeship.com/projects/97914)
|
4
4
|
|
5
5
|
## Installing this tool
|
6
|
-
This command line helper for
|
6
|
+
This command line helper for Bitbucket Server is written in Ruby and is deployed as a [Ruby Gem](https://rubygems.org/gems/atlassian-stash/). Installation is easy, simply run the following command
|
7
7
|
|
8
8
|
```
|
9
9
|
#!text
|
@@ -15,7 +15,7 @@ $> gem install atlassian-stash
|
|
15
15
|
Once the gem is installed, the command `stash` will be in your `$PATH`
|
16
16
|
|
17
17
|
## Configuration and usage
|
18
|
-
Run `stash configure`. This will prompt for details about your
|
18
|
+
Run `stash configure`. This will prompt for details about your Bitbucket Server instance. If no password is provided, then you will be prompted for a password when executing commands to Bitbucket Server.
|
19
19
|
|
20
20
|
The global configuration file lives at `$HOME/.stashconfig.yml` and any options in a similarly named `.stashconfig.yml` file in the root of a git repository will take precedence.
|
21
21
|
|
@@ -36,7 +36,7 @@ The `stash configure` utility will not prompt you for this. If you wish to use `
|
|
36
36
|
|
37
37
|
|
38
38
|
### Creating a pull request
|
39
|
-
Use the `pull-request` command to create a pull request in
|
39
|
+
Use the `pull-request` command to create a pull request in Bitbucket Server. For example:
|
40
40
|
|
41
41
|
```
|
42
42
|
#!text
|
@@ -51,13 +51,13 @@ See the usage for command details
|
|
51
51
|
$> stash help pull-request
|
52
52
|
```
|
53
53
|
|
54
|
-
### Opening the
|
55
|
-
Use the `browse` command to open the
|
54
|
+
### Opening the Bitbucket Server web UI
|
55
|
+
Use the `browse` command to open the Bitbucket Server UI for your repository in the browser.
|
56
56
|
|
57
57
|
```
|
58
58
|
#!text
|
59
59
|
$> stash browse -b develop
|
60
|
-
Open the browser at the
|
60
|
+
Open the browser at the Bitbucket Server repository page for the branch 'develop'
|
61
61
|
```
|
62
62
|
|
63
63
|
For more options, see the help
|
@@ -73,12 +73,12 @@ Running `stash configure` will prepopulate `~/.stashconfig.yml` with a variety o
|
|
73
73
|
|
74
74
|
```
|
75
75
|
#!yaml
|
76
|
-
username: seb # username to connect to
|
77
|
-
password: s3cr3t # password for user. If ommitted, you will be prompted at the terminal when making a request to
|
78
|
-
stash_url: https://
|
79
|
-
remote: upstream # Pull requests will be created in the
|
76
|
+
username: seb # username to connect to Bitbucket Server server.
|
77
|
+
password: s3cr3t # password for user. If ommitted, you will be prompted at the terminal when making a request to Bitbucket Server
|
78
|
+
stash_url: https://bitbucket.server.com # fully qualified Bitbucket Server url
|
79
|
+
remote: upstream # Pull requests will be created in the Bitbucket Server repository specified by this remote
|
80
80
|
open: true # opens newly created pull requests in the browser
|
81
|
-
ssl_no_verify: true # do not check ssl certificates for the configured
|
81
|
+
ssl_no_verify: true # do not check ssl certificates for the configured Bitbucket Server server
|
82
82
|
```
|
83
83
|
|
84
84
|
## Troubleshooting
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.name = "atlassian-stash"
|
18
18
|
gem.homepage = "https://bitbucket.org/atlassian/stash-command-line-tools"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = "Command line tools for
|
21
|
-
gem.description = "Provides convenient functions for interacting with
|
20
|
+
gem.summary = "Command line tools for Bitbucket Server"
|
21
|
+
gem.description = "Provides convenient functions for interacting with Bitbucket Server through the command line"
|
22
22
|
gem.email = "sruiz@atlassian.com"
|
23
23
|
gem.authors = ["Seb Ruiz"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/bin/stash
CHANGED
@@ -9,7 +9,7 @@ require 'pathname'
|
|
9
9
|
|
10
10
|
program :name, "Atlassian Stash CLI"
|
11
11
|
program :version, Atlassian::Stash::Version::STRING
|
12
|
-
program :description, "Provides convenient functions for interacting with Atlassian
|
12
|
+
program :description, "Provides convenient functions for interacting with Atlassian Bitbucket Server through the command line"
|
13
13
|
|
14
14
|
include Atlassian::Stash
|
15
15
|
include Atlassian::Stash::Git
|
@@ -18,7 +18,7 @@ $configFileName = ".stashconfig.yml"
|
|
18
18
|
$configFile = File.join(ENV['HOME'], $configFileName)
|
19
19
|
|
20
20
|
def load_config
|
21
|
-
raise "No
|
21
|
+
raise "No Bitbucket Server configuration found; please run configure" unless File.exists? $configFile
|
22
22
|
config = YAML.load_file($configFile)
|
23
23
|
raise "Stash configuration file is incomplete, please re-run configure" unless config['username'] and config['stash_url']
|
24
24
|
|
@@ -44,16 +44,16 @@ end
|
|
44
44
|
|
45
45
|
command 'configure' do |c|
|
46
46
|
c.syntax = 'configure'
|
47
|
-
c.description = 'Setup configuration details to your
|
48
|
-
c.example 'stash configure --username sebr --password s3cre7 --
|
49
|
-
c.option '--username user', String, 'Writes your
|
50
|
-
c.option '--password password', String, 'Writes your
|
51
|
-
c.option '--stashUrl', String, 'Writes the
|
52
|
-
c.option '--remote', String, 'Pull requests will be created in the
|
47
|
+
c.description = 'Setup configuration details to your Bitbucket Server instance'
|
48
|
+
c.example 'stash configure --username sebr --password s3cre7 --stashUrl http://bitbucket.mycompany.com', 'Setup Bitbucket Server CLI with credentials to the Bitbucket Server instance'
|
49
|
+
c.option '--username user', String, 'Writes your Bitbucket Server username to the configuration file'
|
50
|
+
c.option '--password password', String, 'Writes your Bitbucket Server user password to the configuration file. If omitted, password will be prompted to be entered'
|
51
|
+
c.option '--stashUrl url', String, 'Writes the Bitbucket Server hostname to the configuration file'
|
52
|
+
c.option '--remote remote', String, 'Pull requests will be created in the Bitbucket Server repository specified by the given remote'
|
53
53
|
c.action do |args, options|
|
54
|
-
username = options.username ? options.username : ask("
|
55
|
-
password = options.password ? options.password : ask("
|
56
|
-
stashUrl = options.stashUrl ? options.stashUrl : ask("
|
54
|
+
username = options.username ? options.username : ask("Bitbucket Server Username: ")
|
55
|
+
password = options.password ? options.password : ask("Bitbucket Server Password (optional): ") { |q| q.echo = "*" }
|
56
|
+
stashUrl = options.stashUrl ? options.stashUrl : ask("Bitbucket Server URL: ")
|
57
57
|
remote = options.remote ? options.remote : ask("Remote (optional): ")
|
58
58
|
|
59
59
|
c = {
|
@@ -83,10 +83,10 @@ command 'pull-request' do |c|
|
|
83
83
|
end
|
84
84
|
|
85
85
|
c.syntax = 'pull-request [sourceBranch] targetBranch [@reviewer1 @reviewer2] [options]'
|
86
|
-
c.description = 'Create a pull request in
|
86
|
+
c.description = 'Create a pull request in Bitbucket Server'
|
87
87
|
c.option '-d DESCRIPTION', '--description DESCRIPTION', String, 'Use the following description when creating the pull request'
|
88
88
|
c.option '-T TITLE', '--title TITLE', String, 'Use the following title when creating the pull request'
|
89
|
-
c.option '-r remote', '--remote remote', String, 'Creates the pull request in the
|
89
|
+
c.option '-r remote', '--remote remote', String, 'Creates the pull request in the Bitbucket Server repository specified by the given remote'
|
90
90
|
c.option '-o', '--open', 'Open the created pull request page in a web browser'
|
91
91
|
c.example 'stash pull-request topicBranch master @michael', "Create a pull request from branch 'topicBranch' into 'master' with 'michael' added as a reviewer"
|
92
92
|
c.example 'stash pull-request master', "Create a pull request from the current git branch into 'master'"
|
@@ -147,16 +147,19 @@ command 'pull-request' do |c|
|
|
147
147
|
end
|
148
148
|
|
149
149
|
command 'browse' do |c|
|
150
|
-
c.syntax = 'browse [browse|commits|pull-requests]'
|
151
|
-
c.description = 'Open the
|
152
|
-
c.option '-b branch', '--branch branch', String, 'Open the
|
153
|
-
c.option '-r remote', '--remote remote', String, 'Creates the pull request in the
|
150
|
+
c.syntax = 'browse [browse|commits|pull-requests] [path]'
|
151
|
+
c.description = 'Open the Bitbucket Server web ui for this repository'
|
152
|
+
c.option '-b branch', '--branch branch', String, 'Open the Bitbucket Server web ui at the specified branch, tag or commit hash. Defaults to the current branch'
|
153
|
+
c.option '-r remote', '--remote remote', String, 'Creates the pull request in the Bitbucket Server repository specified by the given remote'
|
154
|
+
c.option '-l lineNumber', '--lineNumber lineNumber', Integer, 'Open the Bitbucket Server web ui at the specified file, highlighting the specified line number. Valid only when used with browse when path is specified'
|
154
155
|
c.example 'stash browse -b master', 'Open the files view for this repository at the current branch'
|
155
156
|
c.example 'stash browse -r upstream', 'Open the files view for the "upstream" remote repository'
|
157
|
+
c.example 'stash browse browse -l 42 path/to/a/file', 'Open the files view for this repository at the specified file on the current branch, highlighting the specified line'
|
156
158
|
|
157
159
|
c.action do |args, options|
|
158
160
|
|
159
161
|
tab = args.shift unless args.empty?
|
162
|
+
path = args.shift unless args.empty?
|
160
163
|
|
161
164
|
config = load_config
|
162
165
|
|
@@ -164,13 +167,18 @@ command 'browse' do |c|
|
|
164
167
|
|
165
168
|
branch = options.branch || get_current_branch
|
166
169
|
|
167
|
-
|
170
|
+
if tab == 'browse' && path
|
171
|
+
url = repoInfo.repoUrl(tab, branch, filePath: path, lineNumber: options.lineNumber)
|
172
|
+
else
|
173
|
+
url = repoInfo.repoUrl(tab, branch)
|
174
|
+
end
|
175
|
+
Launchy.open url
|
168
176
|
end
|
169
177
|
end
|
170
178
|
|
171
179
|
|
172
180
|
default_command :help
|
173
|
-
program :help_formatter, :compact
|
181
|
+
#program :help_formatter, :compact
|
174
182
|
program :help, 'Authors', 'Seb Ruiz <sruiz@atlassian.com>'
|
175
183
|
program :help, 'Website', 'https://bitbucket.org/atlassian/stash-command-line-tools'
|
176
184
|
|
@@ -23,11 +23,13 @@ module Atlassian
|
|
23
23
|
repoPath
|
24
24
|
end
|
25
25
|
|
26
|
-
def repoUrl(suffix, branch)
|
26
|
+
def repoUrl(suffix, branch, options = {})
|
27
|
+
filePath = options[:filePath]
|
28
|
+
lineNumber = options[:lineNumber]
|
27
29
|
uri = URI.parse(@config["stash_url"])
|
28
|
-
path = repoPath + (suffix.nil? ? '' : '/' + suffix)
|
29
|
-
uri
|
30
|
-
|
30
|
+
uri.path = repoPath + (suffix.nil? ? '' : '/' + suffix)
|
31
|
+
uri = RepoInfo.appendFilePathAndFragment(uri, filePath, lineNumber)
|
32
|
+
|
31
33
|
if (!branch.nil? and !branch.empty?)
|
32
34
|
q = uri.query || ''
|
33
35
|
q = q + (q.empty? ? '' : '&') + 'at=' + branch unless branch.nil?
|
@@ -37,6 +39,18 @@ module Atlassian
|
|
37
39
|
uri.to_s
|
38
40
|
end
|
39
41
|
|
42
|
+
def self.appendFilePathAndFragment(uri, filePath, lineNumber)
|
43
|
+
if filePath && !filePath.empty?
|
44
|
+
uri.path = uri.path + (filePath.start_with?('/') ? filePath : "/#{filePath}")
|
45
|
+
|
46
|
+
if lineNumber && !lineNumber.nil?
|
47
|
+
uri.fragment = lineNumber.to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
uri
|
52
|
+
end
|
53
|
+
|
40
54
|
def self.create (config, remote=nil)
|
41
55
|
config = Hash.new if config.nil?
|
42
56
|
remote = config["remote"] if (remote.nil? || remote.empty?)
|
@@ -84,6 +84,22 @@ class TestStashRepoInfo < Minitest::Test
|
|
84
84
|
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash', ri.repoUrl(nil, nil)
|
85
85
|
end
|
86
86
|
|
87
|
+
should "create expected repo url with context, branch and filePath" do
|
88
|
+
config = {
|
89
|
+
'stash_url' => 'https://www.stash.com/foo'
|
90
|
+
}
|
91
|
+
ri = RepoInfo.create config
|
92
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/browse/path/to/file?at=develop', ri.repoUrl('browse', 'develop', filePath: 'path/to/file')
|
93
|
+
end
|
94
|
+
|
95
|
+
should "create expected repo url with context, branch, filePath and lineNumber" do
|
96
|
+
config = {
|
97
|
+
'stash_url' => 'https://www.stash.com/foo'
|
98
|
+
}
|
99
|
+
ri = RepoInfo.create config
|
100
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/browse/path/to/file?at=develop#1337', ri.repoUrl('browse', 'develop', filePath: 'path/to/file', lineNumber: 1337)
|
101
|
+
end
|
102
|
+
|
87
103
|
should "create expected repo url with path and branch" do
|
88
104
|
config = {
|
89
105
|
'stash_url' => 'https://www.stash.com/foo'
|
@@ -99,5 +115,65 @@ class TestStashRepoInfo < Minitest::Test
|
|
99
115
|
ri = RepoInfo.create config
|
100
116
|
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/commits?git=ftw&at=develop', ri.repoUrl('commits', 'develop')
|
101
117
|
end
|
118
|
+
|
119
|
+
should "create expected repo url with context, query, path, branch and filePath" do
|
120
|
+
config = {
|
121
|
+
'stash_url' => 'https://www.stash.com/foo?git=ftw'
|
122
|
+
}
|
123
|
+
ri = RepoInfo.create config
|
124
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/browse/path/to/file?git=ftw&at=develop', ri.repoUrl('browse', 'develop', filePath: 'path/to/file')
|
125
|
+
end
|
126
|
+
|
127
|
+
should "create expected repo url with context, query, branch, filePath and lineNumber" do
|
128
|
+
config = {
|
129
|
+
'stash_url' => 'https://www.stash.com/foo?git=ftw'
|
130
|
+
}
|
131
|
+
ri = RepoInfo.create config
|
132
|
+
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/browse/path/to/file?git=ftw&at=develop#1337', ri.repoUrl('browse', 'develop', filePath: 'path/to/file', lineNumber: 1337)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "append file path and line number to uri" do
|
137
|
+
should 'Append a file path to the specified uri' do
|
138
|
+
uri = URI.parse('http://example.com/browse')
|
139
|
+
expected = 'http://example.com/browse/path/to/file'
|
140
|
+
|
141
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, 'path/to/file', nil).to_s
|
142
|
+
end
|
143
|
+
|
144
|
+
should 'Append a file path with leading slash to the specified uri' do
|
145
|
+
uri = URI.parse('http://example.com/browse')
|
146
|
+
expected = 'http://example.com/browse/path/to/file'
|
147
|
+
|
148
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, '/path/to/file', nil).to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
should 'Append a file path and line number to the specified uri' do
|
152
|
+
uri = URI.parse('http://example.com/browse')
|
153
|
+
expected = 'http://example.com/browse/path/to/file#1337'
|
154
|
+
|
155
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, 'path/to/file', 1337).to_s
|
156
|
+
end
|
157
|
+
|
158
|
+
should 'Append a file path with leading slash and line number to the specified uri' do
|
159
|
+
uri = URI.parse('http://example.com/browse')
|
160
|
+
expected = 'http://example.com/browse/path/to/file#1337'
|
161
|
+
|
162
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, '/path/to/file', 1337).to_s
|
163
|
+
end
|
164
|
+
|
165
|
+
should 'Return the specified uri unmodified if both filePath and lineNumber is nil' do
|
166
|
+
expected = 'http://example.com/browse'
|
167
|
+
uri = URI.parse(expected)
|
168
|
+
|
169
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, nil, nil).to_s
|
170
|
+
end
|
171
|
+
|
172
|
+
should 'Return the specified uri unmodified if filePath is the empty string and lineNumber is nil' do
|
173
|
+
expected = 'http://example.com/browse'
|
174
|
+
uri = URI.parse(expected)
|
175
|
+
|
176
|
+
assert_equal expected, RepoInfo.appendFilePathAndFragment(uri, '', nil).to_s
|
177
|
+
end
|
102
178
|
end
|
103
179
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlassian-stash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seb Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
- - '>='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
description: Provides convenient functions for interacting with
|
181
|
+
description: Provides convenient functions for interacting with Bitbucket Server through
|
182
182
|
the command line
|
183
183
|
email: sruiz@atlassian.com
|
184
184
|
executables:
|
@@ -229,5 +229,5 @@ rubyforge_project:
|
|
229
229
|
rubygems_version: 2.0.14
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
|
-
summary: Command line tools for
|
232
|
+
summary: Command line tools for Bitbucket Server
|
233
233
|
test_files: []
|