stash_cli 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stash_cli/cli.rb +46 -10
- data/lib/stash_cli/git_utils.rb +4 -0
- data/lib/stash_cli/project.rb +12 -0
- data/lib/stash_cli/pull_request.rb +1 -1
- data/lib/stash_cli/templates/stash_cli.yml.erb +10 -0
- data/lib/stash_cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85972d5793f307d24064947ea8bb06d761f3454b
|
4
|
+
data.tar.gz: a4f27190b20c818a5444179c4ad96797c93fff96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb32178046b6588656ccd6b93d072f1c382eebf7720aed4caffa144290a7adb38374a3078803bb75e23808cb3f1bb9d29900eb5ff49ed94c152a9c61b81ca21
|
7
|
+
data.tar.gz: a598cf00ec8de8851c0584d43fe3a558d4daf28411d3e9baa0538ff46848232833680e94cb9550a65160ae32593b489af1e5b2e17e957e4012910ea02947beed
|
data/lib/stash_cli/cli.rb
CHANGED
@@ -5,11 +5,14 @@ require 'base64'
|
|
5
5
|
|
6
6
|
require 'stash_cli/client'
|
7
7
|
require 'stash_cli/git_utils'
|
8
|
+
require 'stash_cli/project'
|
8
9
|
|
9
10
|
module StashCLI
|
10
11
|
class CLI < Thor
|
11
12
|
include Thor::Actions
|
12
13
|
|
14
|
+
attr_reader :project
|
15
|
+
|
13
16
|
def self.source_root
|
14
17
|
File.dirname(__FILE__)
|
15
18
|
end
|
@@ -65,7 +68,7 @@ module StashCLI
|
|
65
68
|
def branches
|
66
69
|
configure
|
67
70
|
client = Client.new(configatron.server, configatron.auth_token)
|
68
|
-
resp = client.branches(
|
71
|
+
resp = client.branches(project.project, project.source_slug)
|
69
72
|
resp['values'].each do |value|
|
70
73
|
say value['displayId']
|
71
74
|
end
|
@@ -237,16 +240,16 @@ module StashCLI
|
|
237
240
|
def default_pr(title)
|
238
241
|
reviewers = initial_reviewers
|
239
242
|
|
240
|
-
target_branch =
|
243
|
+
target_branch = project.target_branch
|
241
244
|
target_branch = options[:branch] if options[:branch]
|
242
245
|
|
243
246
|
opts = {
|
244
247
|
title: title,
|
245
|
-
project:
|
248
|
+
project: project.project,
|
246
249
|
from_branch: GitUtils.current_branch,
|
247
|
-
from_slug:
|
250
|
+
from_slug: project.source_slug,
|
248
251
|
target_branch: target_branch,
|
249
|
-
target_slug:
|
252
|
+
target_slug: project.target_slug,
|
250
253
|
reviewers: reviewers
|
251
254
|
}
|
252
255
|
|
@@ -260,11 +263,11 @@ module StashCLI
|
|
260
263
|
def interactive_pr(title)
|
261
264
|
|
262
265
|
target_branch =
|
263
|
-
ask("target branch [#{
|
266
|
+
ask("target branch [#{project.target_branch}]:").strip
|
264
267
|
|
265
268
|
description = get_description(target_branch)
|
266
269
|
|
267
|
-
target_branch =
|
270
|
+
target_branch = project.target_branch if target_branch.empty?
|
268
271
|
|
269
272
|
reviewers = initial_reviewers
|
270
273
|
|
@@ -281,11 +284,11 @@ module StashCLI
|
|
281
284
|
|
282
285
|
opts = {
|
283
286
|
title: title,
|
284
|
-
project:
|
287
|
+
project: project.project,
|
285
288
|
from_branch: GitUtils.current_branch,
|
286
|
-
from_slug:
|
289
|
+
from_slug: project.source_slug,
|
287
290
|
target_branch: target_branch,
|
288
|
-
target_slug:
|
291
|
+
target_slug: project.target_slug,
|
289
292
|
reviewers: reviewers
|
290
293
|
}
|
291
294
|
|
@@ -303,6 +306,39 @@ module StashCLI
|
|
303
306
|
say 'generate a basic config with "stash init"'
|
304
307
|
exit 1
|
305
308
|
end
|
309
|
+
|
310
|
+
repo_dir = GitUtils.repo_dir
|
311
|
+
proj_file = File.join(repo_dir, '.stash-proj')
|
312
|
+
|
313
|
+
if File.exist?(proj_file)
|
314
|
+
say 'using project from .stash-proj file'
|
315
|
+
project_name = File.read('.stash-proj').strip
|
316
|
+
|
317
|
+
# If you're declaring the project it had better exist
|
318
|
+
unless configatron.projects.has_key?(project_name)
|
319
|
+
say "!! project: #{project_name} requested but not defined !!"
|
320
|
+
say 'add this project to your .stash_cli.yml or remove the .stash-proj file'
|
321
|
+
exit 1
|
322
|
+
end
|
323
|
+
else
|
324
|
+
project_name = File.basename(repo_dir)
|
325
|
+
end
|
326
|
+
|
327
|
+
if configatron.projects.has_key?(project_name)
|
328
|
+
say "using defined project: #{project_name}"
|
329
|
+
@project = Project.new(
|
330
|
+
configatron.projects[project_name].project,
|
331
|
+
configatron.projects[project_name].source_slug,
|
332
|
+
configatron.projects[project_name].target_slug,
|
333
|
+
configatron.projects[project_name].target_branch)
|
334
|
+
|
335
|
+
else
|
336
|
+
@project = Project.new(
|
337
|
+
configatron.defaults.project,
|
338
|
+
configatron.defaults.source_slug,
|
339
|
+
configatron.defaults.target_slug,
|
340
|
+
configatron.defaults.target_branch)
|
341
|
+
end
|
306
342
|
end
|
307
343
|
|
308
344
|
def ask_required(statement, *args)
|
data/lib/stash_cli/git_utils.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
module StashCLI
|
2
|
+
class Project
|
3
|
+
attr_reader :project, :source_slug, :target_slug, :target_branch
|
4
|
+
|
5
|
+
def initialize(project, source_slug, target_slug, target_branch)
|
6
|
+
@project = project
|
7
|
+
@source_slug = source_slug
|
8
|
+
@target_slug = target_slug
|
9
|
+
@target_branch = target_branch
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -12,6 +12,16 @@ defaults:
|
|
12
12
|
target_slug: <%= @target %>
|
13
13
|
target_branch: <%= @target_branch %>
|
14
14
|
|
15
|
+
# You can specify a list of projects here. Projects are detected via the
|
16
|
+
# basename of the git repo directory or via a .stash-proj file at
|
17
|
+
# <git repo basename>/.stash-proj. The must contain one line: the project name
|
18
|
+
# projects:
|
19
|
+
# my-proj:
|
20
|
+
# project: FOO
|
21
|
+
# source_slug: bar
|
22
|
+
# target_slug: baz
|
23
|
+
# target_branch: master
|
24
|
+
|
15
25
|
# You can always specify reviewers in interactive mode, but these are here to
|
16
26
|
# provide convenient sets of frequently-included reviewers. The names here are
|
17
27
|
# the "names" for the desired set of stash users. You can get a (limit 1000)
|
data/lib/stash_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stash_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Chun-Lum
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configatron
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/stash_cli/cli.rb
|
145
145
|
- lib/stash_cli/client.rb
|
146
146
|
- lib/stash_cli/git_utils.rb
|
147
|
+
- lib/stash_cli/project.rb
|
147
148
|
- lib/stash_cli/pull_request.rb
|
148
149
|
- lib/stash_cli/templates/stash_cli.yml.erb
|
149
150
|
- lib/stash_cli/version.rb
|