sah 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df17335238e88fbccf43783368514990177ae205
4
- data.tar.gz: 6391cde337e7e556bfb44d045a5cd86496c44c35
3
+ metadata.gz: 18642a288281aa66cd1d5dfb37711ec1d4040f0e
4
+ data.tar.gz: d65bf5d5ac49ec5a62daf08cd276f732278c38d1
5
5
  SHA512:
6
- metadata.gz: 10ee1527f31c4b973133b43c3c28cb68686ea73d6289510de7e58663ef123024fa6023967ea2ebf926cae8195970f0abcc9ce4942876ea048050d47578adeab8
7
- data.tar.gz: 99db2c7d06eb40ed66f92f8f7fa618ffa8f6384163a1c2bcfdee7890a521181a4e645a4935bb3b2e495ed78706fe00ad8b52fd6eb63b2d7077e40856aa9abad4
6
+ metadata.gz: 20f93b1390e2c3cb64178f5b2003d94b89e0080d32956b3c3bacf27ae87609852fb9be8e00414b35b0e1aaa72d393f82ee28d7d6003ff383021234390eee8bdb
7
+ data.tar.gz: 83b3fbf7d1de1321c1a698562aa1cbdc8a39d02461612e5b15be82f6cbf91c0674b7f4d2524d053f3e65ebad0c242605579d664badcc3856e64bd098b8fc33aa
data/README.md CHANGED
@@ -30,7 +30,7 @@ If you use multiple stash, define profile(s) and specify it.
30
30
  ### clone
31
31
 
32
32
  sah clone PROJECT/REPO
33
- > git clone ssh://git@example.com:7999/project/REPO
33
+ > git clone ssh://git@example.com:7999/PROJECT/REPO
34
34
 
35
35
  sah clone REPO
36
36
  > git clone ssh://git@example.com:7999/~YOUR_NAME/ERPO
@@ -103,7 +103,7 @@ If you use multiple stash, define profile(s) and specify it.
103
103
  - `git config --global sah.config.upstream-prevent-push true`
104
104
  (the same as `--prevent-push` option)
105
105
  Setting this option to true will Prevent push to upstream repository.
106
- - `git config --global sah.config.sah.git-protocol [ssh|http]`
106
+ - `git config --global sah.config.protocol [ssh|http]`
107
107
  Setting this option to specify git protocol. (default: ssh)
108
108
 
109
109
  ### user
data/lib/sah/api.rb CHANGED
@@ -12,7 +12,7 @@ module Sah
12
12
  base_url = (config.url).to_s.sub(/#{config.url.path}$/, '')
13
13
  @conn = Faraday.new(url: base_url) do |faraday|
14
14
  faraday.response :json
15
- # faraday.response :logger
15
+ faraday.response :logger if config.verbose
16
16
  faraday.adapter Faraday.default_adapter
17
17
  faraday.basic_auth config.user, config.password
18
18
  end
data/lib/sah/cli.rb CHANGED
@@ -8,11 +8,14 @@ module Sah
8
8
  class_option :profile,
9
9
  type: :string, default: (ENV["SAH_DEFAULT_PROFILE"] || :default),
10
10
  desc: "Set a specific profile"
11
+ class_option :verbose,
12
+ type: :boolean, default: false,
13
+ desc: "Turn on/off verbose mode"
11
14
 
12
15
  desc "clone REPOS", "Clone repository"
13
16
  long_desc <<-LONG_DESCRIPTION
14
17
  sah clone PROJECT/REPO
15
- \x5> git clone ssh://git@example.com:7999/project/REPO
18
+ \x5> git clone ssh://git@example.com:7999/PROJECT/REPO
16
19
 
17
20
  sah clone REPO
18
21
  \x5> git clone ssh://git@example.com:7999/~YOUR_NAME/REPO
@@ -29,11 +32,11 @@ module Sah
29
32
  end
30
33
  repository = res.body
31
34
  remote_url =
32
- repository["links"]["clone"].find{ |e| e["name"] == config.git_protocol }["href"]
35
+ repository["links"]["clone"].find{ |e| e["name"] == config.protocol }["href"]
33
36
  system "git", "clone", remote_url
34
37
  end
35
38
 
36
- desc "create [PROJECT] [--name REPO_NAME]", "Create repository"
39
+ desc "create [PROJECT]", "Create repository"
37
40
  long_desc <<-LONG_DESCRIPTION
38
41
  sah create
39
42
  \x5# create repository
@@ -57,11 +60,11 @@ module Sah
57
60
  abort res.body["errors"].first["message"]
58
61
  end
59
62
  remote_url =
60
- res.body["links"]["clone"].find{ |e| e["name"] == config.git_protocol }["href"]
63
+ res.body["links"]["clone"].find{ |e| e["name"] == config.protocol }["href"]
61
64
  system "git", "remote", "add", "origin", remote_url
62
65
  end
63
66
 
64
- desc "fork [REPO] [--name REPO_NAME]", "Fork repository"
67
+ desc "fork [REPO]", "Fork repository"
65
68
  long_desc <<-LONG_DESCRIPTION
66
69
  sah fork
67
70
  \x5# fork from current repository to ~YOUR_NAME/REPO
@@ -144,7 +147,7 @@ module Sah
144
147
  end
145
148
  end
146
149
 
147
- desc "upstream [--add-remote [--fetch-pull-request] [--prevent-push]]",
150
+ desc "upstream",
148
151
  "Show upstream information"
149
152
  long_desc <<-LONG_DESCRIPTION
150
153
  upstream
@@ -166,7 +169,7 @@ module Sah
166
169
  end
167
170
  repository = res.body
168
171
  upstream_url =
169
- repository["origin"]["links"]["clone"].find{ |e| e["name"] == config.git_protocol }["href"]
172
+ repository["origin"]["links"]["clone"].find{ |e| e["name"] == config.protocol }["href"]
170
173
  if options[:"add-remote"]
171
174
  system "git", "remote", "add", "upstream", upstream_url
172
175
  if config.upstream_fetch_pull_request || options[:"fetch-pull-request"]
@@ -215,7 +218,7 @@ module Sah
215
218
  private
216
219
 
217
220
  def config
218
- @config ||= Config.new(options[:profile])
221
+ @config ||= Config.new(options[:profile], verbose: options[:verbose])
219
222
  end
220
223
 
221
224
  def api
data/lib/sah/config.rb CHANGED
@@ -4,13 +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
- :git_protocol
7
+ :protocol, :verbose
8
8
 
9
- def initialize(profile)
9
+ def initialize(profile, verbose: false)
10
10
  @user, @password, @url = nil, nil, nil
11
11
  @upstream_fetch_pull_request = false
12
12
  @upstream_prevent_push = false
13
- @git_protocol = "ssh"
13
+ @protocol = "ssh"
14
+ @verbose = verbose
14
15
 
15
16
  profile_prefix = "sah\.profile\.#{profile}"
16
17
  config_prefix = "sah\.config"
@@ -27,14 +28,17 @@ module Sah
27
28
  @upstream_fetch_pull_request = ($1 == "true")
28
29
  when /#{config_prefix}\.upstream-prevent-push (.*)$/
29
30
  @upstream_prevent_push = ($1 == "true")
30
- when /#{config_prefix}\.git-protocol (.*)$/
31
- @git_protocol = $1
31
+ when /#{config_prefix}\.protocol (.*)$/
32
+ @protocol = $1
32
33
  end
33
34
  end
34
35
 
35
36
  unless @user && @password && @url
36
37
  abort "Invalid profile: #{profile}"
37
38
  end
39
+ unless ["ssh", "http"].include? @protocol
40
+ abort "protocol must be set to ssh or http: #{@protocol}"
41
+ end
38
42
  end
39
43
  end
40
44
  end
data/lib/sah/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sah
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - f440