atlassian-stash 0.4.1 → 0.5.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 +21 -2
- data/VERSION +1 -1
- data/bin/stash +8 -1
- data/lib/atlassian/stash/git.rb +7 -1
- data/lib/atlassian/stash/pull_request.rb +1 -1
- data/lib/atlassian/stash/repo_info.rb +2 -2
- data/test/test_stash-git.rb +10 -10
- data/test/test_stash-repo-info.rb +7 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 682bc271a57ab40dff60664829c0eb186b85f69c
|
4
|
+
data.tar.gz: 77065a5e776e9a090981dd406d67a315ad346888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d78247c9ade2009da701d9703dde0264cf51928f3c75a3a14eb65760e35e1a43609672866d7151ff57ad3e741d8f296556fa23244131dfc28aa3ced118e052b0
|
7
|
+
data.tar.gz: c1d5600c4575f3099fc91e1ae108d172011c93aa2d680bd0348ece4f873e2698226407dc4f4475500f30a2d74aa5ea6f40822e1b43d6556b362218bf5f060a11
|
data/README.md
CHANGED
@@ -13,7 +13,25 @@ $> gem install atlassian-stash
|
|
13
13
|
Once the gem is installed, the command `stash` will be in your `$PATH`
|
14
14
|
|
15
15
|
## Configuration and usage
|
16
|
-
Run `stash configure`. This will prompt for details about your Stash instance. If no password is provided, then you will be prompted for a password when executing commands to Stash.
|
16
|
+
Run `stash configure`. This will prompt for details about your Stash instance. If no password is provided, then you will be prompted for a password when executing commands to Stash.
|
17
|
+
|
18
|
+
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.
|
19
|
+
|
20
|
+
### Passwords
|
21
|
+
There are currently two ways to store your password in the configuration file. You may store it as plain text with the key `password`, for example:
|
22
|
+
|
23
|
+
```
|
24
|
+
password: s3cre7
|
25
|
+
```
|
26
|
+
|
27
|
+
Or you may store a command string with the `passwordeval` key which allows you to use any encrypted method you like in order to store your password. For example, if using gpg:
|
28
|
+
|
29
|
+
```
|
30
|
+
passwordeval: gpg --no-tty --quiet --decrypt ~/.secret.gpg
|
31
|
+
```
|
32
|
+
|
33
|
+
The `stash configure` utility will not prompt you for this. If you wish to use `passwordeval`, omit a password during the configuration and add it to `~/.stashconfig.yml` afterwards.
|
34
|
+
|
17
35
|
|
18
36
|
### Creating a pull request
|
19
37
|
Use the `pull-request` command to create a pull request in Stash. For example:
|
@@ -56,6 +74,7 @@ Running `stash configure` will prepopulate `~/.stashconfig.yml` with a variety o
|
|
56
74
|
username: seb # username to connect to stash server.
|
57
75
|
password: s3cr3t # password for user. If ommitted, you will be prompted at the terminal when making a request to Stash
|
58
76
|
stash_url: https://stash.server.com # fully qualified stash url
|
77
|
+
remote: upstream # Pull requests will be created in the Stash repository specified by this remote
|
59
78
|
open: true # opens newly created pull requests in the browser
|
60
79
|
ssl_no_verify: true # do not check ssl certificates for the configured stash server
|
61
80
|
```
|
@@ -111,4 +130,4 @@ version:write -- writes out an explicit version
|
|
111
130
|
|
112
131
|
```
|
113
132
|
$> rake release
|
114
|
-
```
|
133
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bin/stash
CHANGED
@@ -21,6 +21,11 @@ def load_config
|
|
21
21
|
raise "No Stash 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
|
+
|
25
|
+
if config['password'].nil? && !config['passwordeval'].nil?
|
26
|
+
config['password'] = `#{config['passwordeval']}`.strip
|
27
|
+
end
|
28
|
+
|
24
29
|
config.merge! repo_config if repo_config
|
25
30
|
config
|
26
31
|
end
|
@@ -112,7 +117,6 @@ command 'pull-request' do |c|
|
|
112
117
|
target = target['remotes/'.size..-1]
|
113
118
|
end
|
114
119
|
|
115
|
-
options.src_remote = options.remote
|
116
120
|
if not is_branch?(source)
|
117
121
|
if not is_branch?("remotes/" + source)
|
118
122
|
raise "fatal: unrecogonized source branch"
|
@@ -120,7 +124,10 @@ command 'pull-request' do |c|
|
|
120
124
|
# If a remote matches, split the remote out of the refspec
|
121
125
|
options.src_remote = source.split('/')[0]
|
122
126
|
source = source.split('/')[1..-1].join('/')
|
127
|
+
else
|
128
|
+
options.src_remote = Atlassian::Stash::Git.get_remote(source)
|
123
129
|
end
|
130
|
+
options.src_remote = options.remote if options.src_remote.nil? || options.src_remote.empty?
|
124
131
|
|
125
132
|
options.target_remote = options.remote
|
126
133
|
if not is_branch?(target)
|
data/lib/atlassian/stash/git.rb
CHANGED
@@ -11,7 +11,7 @@ module Atlassian
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def get_branches()
|
14
|
-
all = %x{git branch -a}.gsub("*","").gsub(" ", "").split("\n")
|
14
|
+
all = %x{git branch --no-color -a}.gsub("*","").gsub(" ", "").split("\n")
|
15
15
|
all.select{|x| not x.include? "->"}
|
16
16
|
end
|
17
17
|
|
@@ -28,6 +28,12 @@ module Atlassian
|
|
28
28
|
%x(git remote -v)
|
29
29
|
end
|
30
30
|
|
31
|
+
def get_remote(branch = nil)
|
32
|
+
remote_branch = %x(git rev-parse --abbrev-ref --symbolic-full-name #{branch}@{u} 2>/dev/null)
|
33
|
+
remote = remote_branch.split('/').first
|
34
|
+
remote == "" ? nil : remote
|
35
|
+
end
|
36
|
+
|
31
37
|
def get_remote_url(remote=nil)
|
32
38
|
remotes = get_remotes
|
33
39
|
return nil if remotes.empty?
|
@@ -136,7 +136,7 @@ module Atlassian
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def git_commit_messages
|
139
|
-
@commit_messages ||= `git log --reverse --format=%s #{@target_ref}..#{@source_ref}`
|
139
|
+
@commit_messages ||= `git log --no-color --reverse --format=%s #{@target_ref}..#{@source_ref}`
|
140
140
|
end
|
141
141
|
|
142
142
|
def parse_proxy(conf)
|
@@ -52,11 +52,11 @@ module Atlassian
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
if m = remoteUrl.match(
|
55
|
+
if m = remoteUrl.match(/[\/:]([a-zA-Z~][a-zA-Z0-9_\-]*)\/([[:alnum:]][\w\-\.]*).git$/)
|
56
56
|
return RepoInfo.new(config, m[1], m[2])
|
57
57
|
end
|
58
58
|
raise "Repository does not seem to be hosted in Stash; Remote url: " + remoteUrl
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end
|
62
|
+
end
|
data/test/test_stash-git.rb
CHANGED
@@ -79,16 +79,16 @@ class TestGit < Minitest::Test
|
|
79
79
|
end
|
80
80
|
|
81
81
|
should "branches are matched" do
|
82
|
-
Atlassian::Stash::Git.stubs(:get_branches).returns(
|
83
|
-
"
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
Atlassian::Stash::Git.stubs(:get_branches).returns([
|
83
|
+
"feature",
|
84
|
+
"temp",
|
85
|
+
"master",
|
86
|
+
"remotes/origin/master",
|
87
|
+
"remotes/origin/release/v1.0",
|
88
|
+
"remotes/origin/feature/awesome",
|
89
|
+
"remotes/upstream/master",
|
90
|
+
"remotes/upstream/release/v1.0",
|
91
|
+
"remotes/upstream/feature/Issue7"])
|
92
92
|
assert_equal true, Atlassian::Stash::Git.is_branch?('master')
|
93
93
|
assert_equal true, Atlassian::Stash::Git.is_branch?('remotes/upstream/master')
|
94
94
|
end
|
@@ -14,9 +14,12 @@ class TestStashRepoInfo < Minitest::Test
|
|
14
14
|
assert_equal 'stash', ri.slug
|
15
15
|
end
|
16
16
|
|
17
|
-
should "extracting project key and repo slug from
|
18
|
-
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin
|
19
|
-
|
17
|
+
should "extracting project key and repo slug from SSH remote" do
|
18
|
+
Atlassian::Stash::Git.stubs(:get_remotes).returns("origin sruiz@stash-dev.atlassian.com:STASH/stash.git (push)")
|
19
|
+
|
20
|
+
ri = RepoInfo.create({})
|
21
|
+
assert_equal 'STASH', ri.projectKey
|
22
|
+
assert_equal 'stash', ri.slug
|
20
23
|
end
|
21
24
|
|
22
25
|
should "repo with hyphes" do
|
@@ -88,4 +91,4 @@ class TestStashRepoInfo < Minitest::Test
|
|
88
91
|
assert_equal 'https://www.stash.com/foo/projects/STASH/repos/stash/commits?git=ftw&at=develop', ri.repoUrl('commits', 'develop')
|
89
92
|
end
|
90
93
|
end
|
91
|
-
end
|
94
|
+
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.5.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:
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|