sah 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbea4bc8326aacb553a17e683d23d5a23ea8000a
4
- data.tar.gz: 1ef2ebeed7626f758fee80476babb3eb6b04044d
3
+ metadata.gz: db632c3e30f681ebb32cbd7de8def2f30d48d84d
4
+ data.tar.gz: 78b56e57314886eef1eacc03ef765d977916c847
5
5
  SHA512:
6
- metadata.gz: 05f4c052ba5079b21d789b4e352827643eca0af9363ad23cae207ea12df20bd64ac086f41d2b218f9ba7c3a4f567e300000e2e770b00313a86dbc6df5cf2e4bb
7
- data.tar.gz: 2d15b5d41ae35f306cfa2df2412880863d9b614f37e3aaa048b276dfc60c754140acb21c5c34e8a0ccec05ec7cfd23934f40d09351ab968d656b212f2d406579
6
+ metadata.gz: 353ce0328e18b0f1ec14ce3d481dd4074dc92b1d104cc6885d00fcca2fefbfc256605ae0d97d2a4ba462c6e8f64003eb73833304a2c16dcbc881c02ab33295f4
7
+ data.tar.gz: afd4a367f3beb492d3aa9ca68c8c88ff918119ec6f0b27ca40d853cbe50f7cba2f796101dd910d9454bcfa454f134e632388ecc97df5a620c62291af57397a11
data/README.md CHANGED
@@ -124,7 +124,7 @@ If you use multiple Bitbucket Server, define profile(s) and specify it.
124
124
  sah upstream
125
125
  # show upstream information
126
126
 
127
- sah upstream --add-remote [--fetch-pull-request] [--prevent-push]
127
+ sah upstream --add-remote [--fetch-pull-request] [--prevent-push] [--remote-name=REMOTE-NAME]
128
128
  # add upstream to remote settings
129
129
 
130
130
  #### configutration
@@ -135,6 +135,9 @@ If you use multiple Bitbucket Server, define profile(s) and specify it.
135
135
  - `git config --global sah.config.upstream-prevent-push true`
136
136
  (the same as `--prevent-push` option)
137
137
  Setting this option to true will Prevent push to upstream repository.
138
+ - `git config --global sah.config.upstream-remote-name hoge`
139
+ (the same as `--remote-name` option)
140
+ Setting this option to any value will specify git remote name of upstream repository.
138
141
 
139
142
  ### user
140
143
 
@@ -224,7 +224,7 @@ module Sah
224
224
  def pull_request
225
225
  source_project, source_repository, source_branch = nil, nil, nil
226
226
  if options[:source]
227
- m = options[:source].match(%r{^([^/:]+)/([^/:]+):([^/:]+)$})
227
+ m = options[:source].match(%r{^([^/:]+)/([^/:]+):([^:]+)$})
228
228
  if m.nil?
229
229
  abort "Invalid format: --source #{options[:source]}"
230
230
  end
@@ -240,7 +240,7 @@ module Sah
240
240
 
241
241
  target_project, target_repository, target_branch = nil, nil, nil
242
242
  if options[:target]
243
- m = options[:target].match(%r{^([^/:]+)/([^/:]+):([^/:]+)$})
243
+ m = options[:target].match(%r{^([^/:]+)/([^/:]+):([^:]+)$})
244
244
  if m.nil?
245
245
  abort "Invalid format: --target #{options[:target]}"
246
246
  end
@@ -316,24 +316,27 @@ module Sah
316
316
  upstream
317
317
  \x5# show upstream information
318
318
 
319
- upstream --add-remote [--fetch-pull-request] [--prevent-push]
319
+ upstream --add-remote [--fetch-pull-request] [--prevent-push] [--remote-name=REMOTE-NAME]
320
320
  \x5# add upstream to remote settings
321
321
  LONG_DESCRIPTION
322
322
  method_option :"add-remote", desc: "Add a upstream repository to remote settings"
323
323
  method_option :"fetch-pull-request", desc: "Fetch pull requests"
324
324
  method_option :"prevent-push", desc: "Prevent push to upstream"
325
+ method_option :"remote-name", type: :string, default: "", desc: "Specify a remote name of upstream"
325
326
  def upstream
326
327
  upstream_url =
327
328
  upstream_repository["origin"]["links"]["clone"].find{ |e| e["name"] == config.protocol }["href"]
328
329
 
329
330
  if options[:"add-remote"]
330
- system "git", "remote", "add", "upstream", upstream_url
331
+ remote_name = options["remote-name"]
332
+ remote_name = config.upstream_remote_name if remote_name.nil? || remote_name.empty?
333
+ system "git", "remote", "add", remote_name, upstream_url
331
334
  if config.upstream_fetch_pull_request || options[:"fetch-pull-request"]
332
- %x(git config --add remote.upstream.fetch \
333
- '+refs/pull-requests/*:refs/remotes/upstream/pull-requests/*')
335
+ %x(git config --add remote.#{remote_name}.fetch \
336
+ '+refs/pull-requests/*:refs/remotes/#{remote_name}/pull-requests/*')
334
337
  end
335
338
  if config.upstream_prevent_push || options[:"prevent-push"]
336
- %x(git remote set-url --push upstream "")
339
+ %x(git remote set-url --push #{remote_name} "")
337
340
  end
338
341
  else
339
342
  puts upstream_url
@@ -4,12 +4,14 @@ module Sah
4
4
  class Config
5
5
  attr_accessor :user, :password, :url,
6
6
  :upstream_fetch_pull_request, :upstream_prevent_push,
7
+ :upstream_remote_name,
7
8
  :protocol, :verbose
8
9
 
9
10
  def initialize(profile, verbose: false)
10
11
  @user, @password, @url = nil, nil, nil
11
12
  @upstream_fetch_pull_request = false
12
13
  @upstream_prevent_push = false
14
+ @upstream_remote_name = "upstream"
13
15
  @protocol = "ssh"
14
16
  @verbose = verbose
15
17
 
@@ -28,6 +30,8 @@ module Sah
28
30
  @upstream_fetch_pull_request = ($1 == "true")
29
31
  when /#{config_prefix}\.upstream-prevent-push (.*)$/
30
32
  @upstream_prevent_push = ($1 == "true")
33
+ when /#{config_prefix}\.upstream-remote-name (.*)$/
34
+ @upstream_remote_name = $1
31
35
  when /#{config_prefix}\.protocol (.*)$/
32
36
  @protocol = $1
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module Sah
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - f440
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor