ghdeploy 0.2.0 → 0.2.1

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: 6b7337590fe342d7eb0847bfc0db55f427fa21ee
4
- data.tar.gz: caae3973494652dd50d238456cecbe7d1cb0eb7c
3
+ metadata.gz: 9fb7ea113254aeb5e3b38eb22b43060c20380c45
4
+ data.tar.gz: 751057cc6ac4cc0a52a1c557277ed2603b6bd3f7
5
5
  SHA512:
6
- metadata.gz: c52cfbd42ea137d34b85b55bd455c39e967832b36e37fea95a40f5239b2ff99ed00ecfe841de6d03428865b6b25bbafafe2b2cd7e54dd06f461166326d40b902
7
- data.tar.gz: 335e4db5a62e75f9b90290624b322fed40fd7112cd4d84d79c241cdfc59d070a67356842c8c6aaec8b7b1cb82550b11967887a043e3c5c03b477ddbe1160ee2b
6
+ metadata.gz: 50a5429c3bf9c990c2f0cf5f14f40ab06daad918b36130d9d94c5be322f79264876e973542ff4d338ae824b57842e9e74774221a63f57600591efa20e8a5da99
7
+ data.tar.gz: f3741da59ca716f4071f3778e55c9c72aca2d0105001add26533fdbf3ace4a1686de6f4addac4bb3ed5eaef84eb9ba799b6ab5ac141441ac805d1dc50d028557
@@ -0,0 +1,29 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ Include:
5
+ - Gemfile
6
+ - lib/**/*
7
+ - spec/**/*
8
+ Exclude:
9
+ - bin/**/*
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Style/GuardClause:
15
+ Enabled: false
16
+
17
+ Style/BlockDelimiters:
18
+ Exclude:
19
+ - 'spec/**/*'
20
+
21
+ Metrics/LineLength:
22
+ Max: 100
23
+
24
+ Metrics/MethodLength:
25
+ Max: 12
26
+
27
+ Metrics/BlockLength:
28
+ Exclude:
29
+ - 'spec/**/*.rb'
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in ghdeploy.gemspec
6
6
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ghdeploy (0.1.6)
4
+ ghdeploy (0.2.0)
5
5
  git (~> 1.5)
6
6
  octokit (~> 4.0)
7
7
  thor (~> 0.20)
@@ -11,6 +11,7 @@ GEM
11
11
  specs:
12
12
  addressable (2.5.2)
13
13
  public_suffix (>= 2.0.2, < 4.0)
14
+ ast (2.4.0)
14
15
  diff-lcs (1.3)
15
16
  faraday (0.15.2)
16
17
  multipart-post (>= 1.2, < 3)
@@ -18,7 +19,12 @@ GEM
18
19
  multipart-post (2.0.0)
19
20
  octokit (4.9.0)
20
21
  sawyer (~> 0.8.0, >= 0.5.3)
21
- public_suffix (3.0.2)
22
+ parallel (1.12.1)
23
+ parser (2.5.1.0)
24
+ ast (~> 2.4.0)
25
+ powerpack (0.1.1)
26
+ public_suffix (3.0.3)
27
+ rainbow (3.0.0)
22
28
  rake (10.5.0)
23
29
  rspec (3.7.0)
24
30
  rspec-core (~> 3.7.0)
@@ -33,10 +39,21 @@ GEM
33
39
  diff-lcs (>= 1.2.0, < 2.0)
34
40
  rspec-support (~> 3.7.0)
35
41
  rspec-support (3.7.1)
42
+ rubocop (0.56.0)
43
+ parallel (~> 1.10)
44
+ parser (>= 2.5)
45
+ powerpack (~> 0.1)
46
+ rainbow (>= 2.2.2, < 4.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (~> 1.0, >= 1.0.1)
49
+ rubocop-rspec (1.22.2)
50
+ rubocop (>= 0.52.1)
51
+ ruby-progressbar (1.9.0)
36
52
  sawyer (0.8.1)
37
53
  addressable (>= 2.3.5, < 2.6)
38
54
  faraday (~> 0.8, < 1.0)
39
55
  thor (0.20.0)
56
+ unicode-display_width (1.3.2)
40
57
 
41
58
  PLATFORMS
42
59
  ruby
@@ -46,6 +63,8 @@ DEPENDENCIES
46
63
  ghdeploy!
47
64
  rake (~> 10.0)
48
65
  rspec (~> 3.0)
66
+ rubocop
67
+ rubocop-rspec
49
68
 
50
69
  BUNDLED WITH
51
70
  1.16.1
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "ghdeploy"
3
+ require 'bundler/setup'
4
+ require 'ghdeploy'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "ghdeploy"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,5 +1,5 @@
1
1
 
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'ghdeploy/version'
5
5
 
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Brandon Joyce']
10
10
  spec.email = ['brandon@sonerdy.com']
11
11
 
12
- spec.summary = %q{Adds a deploy command to git that uses the GitHub deployments API}
13
- spec.description = %q{Run git deploy within a git repository to create a GitHub deployment.}
12
+ spec.summary = 'Adds a deploy command to git that uses the GitHub deployments API'
13
+ spec.description = 'Run git deploy within a git repository to create a GitHub deployment.'
14
14
  spec.homepage = 'https://github.com/sonerdy/ghdeploy'
15
15
  spec.license = 'MIT'
16
16
 
@@ -21,11 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_runtime_dependency 'thor', '~> 0.20'
25
24
  spec.add_runtime_dependency 'git', '~> 1.5'
26
25
  spec.add_runtime_dependency 'octokit', '~> 4.0'
26
+ spec.add_runtime_dependency 'thor', '~> 0.20'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.16'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'rubocop-rspec'
31
33
  end
@@ -1,4 +1,4 @@
1
- require "ghdeploy/version"
1
+ require 'ghdeploy/version'
2
2
 
3
3
  module Ghdeploy
4
4
  end
@@ -4,23 +4,20 @@ require 'ghdeploy/repo_fact_finder'
4
4
  require 'octokit'
5
5
 
6
6
  module Ghdeploy
7
- class CLI < Thor
8
-
7
+ class CLI < Thor
9
8
  option :description
10
9
  option :remote
11
10
 
12
- desc 'deploy', 'Creates a GitHub deployment.'
13
- def deploy(environment, ref)
14
- remote_name = options[:remote] || 'origin'
15
-
16
- facts = RepoFactFinder.new(remote_name)
17
- Octokit.configure { |c| c.api_endpoint = facts.host }
18
- client = Octokit::Client.new(access_token: facts.token)
19
- deployment = client.create_deployment(facts.repo, ref, environment: environment)
20
- puts "Deployment created!" if deployment.url
21
- end
11
+ desc 'deploy', 'Creates a GitHub deployment.'
12
+ def deploy(environment, ref)
13
+ remote_name = options[:remote] || 'origin'
14
+ facts = RepoFactFinder.new(remote_name)
15
+ Octokit.configure { |c| c.api_endpoint = facts.api_endpoint }
16
+ client = Octokit::Client.new(access_token: facts.token)
17
+ deployment = client.create_deployment(facts.repo, ref, environment: environment)
18
+ puts "Deployment created: #{deployment.url}" if deployment.url
19
+ end
22
20
 
23
- default_task :deploy
24
- end
21
+ default_task :deploy
22
+ end
25
23
  end
26
-
@@ -1,8 +1,7 @@
1
1
  require 'git'
2
2
 
3
- # Figures out an API host to use based on the remote for the Git repository
4
3
  class RepoFactFinder
5
- URL_PATTERN = /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?/
4
+ URL_PATTERN = %r{^((http[s]?|ftp):/)?/?([^:/\s]+)((/\w+)*/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?}
6
5
 
7
6
  def initialize(remote_name)
8
7
  @remote_name = remote_name
@@ -10,30 +9,34 @@ class RepoFactFinder
10
9
 
11
10
  attr_reader :remote_name
12
11
 
13
- def host
14
- return @host if @host
12
+ def api_endpoint
13
+ return @api_endpoint if @api_endpoint
15
14
  url = remote.url
16
15
  if url.start_with?('http')
17
16
  matches = URL_PATTERN.match(url)
18
- @host = "#{matches[2]}://api.#{matches[3]}"
17
+ @api_endpoint = "#{matches[2]}://api.#{matches[3]}"
19
18
  else
20
19
  host = url.split('@').last.split(':').first
21
- @host = "https://api.#{host}"
20
+ @api_endpoint = "https://api.#{host}"
22
21
  end
22
+ @api_endpoint = fix_enterprise_api_endpoint(@api_endpoint)
23
23
  end
24
24
 
25
25
  def repo
26
26
  return @repo if @repo
27
- repo = url.split(/\/|:/).last(2).join('/')
27
+ repo = url.split(%r{/|:}).last(2).join('/')
28
28
  @repo = repo.gsub(/(\.git)$/, '')
29
29
  end
30
30
 
31
31
  def token
32
- github_host = host.gsub(/^http[s]?:\/\/api\./, '')
33
- if github_host == 'github.com'
32
+ github_host = api_endpoint.gsub(%r{^http[s]?://}, '')
33
+ if github_host == 'api.github.com'
34
34
  ENV.fetch('GHDEPLOY_TOKEN')
35
35
  else
36
- key = github_host.gsub(/[\.\-]/, '_').upcase
36
+ key = github_host
37
+ .gsub(/[\.\-]/, '_')
38
+ .upcase
39
+ .gsub(%r{/API/V3/}, '')
37
40
  ENV.fetch("GHDEPLOY_#{key}_TOKEN")
38
41
  end
39
42
  end
@@ -47,4 +50,10 @@ class RepoFactFinder
47
50
  def remote
48
51
  @remote ||= Git.open('./').remotes.find { |r| r.name == remote_name }
49
52
  end
53
+
54
+ def fix_enterprise_api_endpoint(host)
55
+ return host if host == 'https://api.github.com'
56
+ enterprise_domain = host.gsub(%r{^http[s]?://api\.}, '')
57
+ "https://#{enterprise_domain}/api/v3/"
58
+ end
50
59
  end
@@ -1,3 +1,3 @@
1
1
  module Ghdeploy
2
- VERSION = "0.2.0"
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Joyce
@@ -11,47 +11,47 @@ cert_chain: []
11
11
  date: 2018-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thor
14
+ name: git
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.20'
19
+ version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.20'
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
- name: git
28
+ name: octokit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: octokit
42
+ name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '0.20'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '0.20'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Run git deploy within a git repository to create a GitHub deployment.
98
126
  email:
99
127
  - brandon@sonerdy.com
@@ -106,6 +134,7 @@ extra_rdoc_files: []
106
134
  files:
107
135
  - ".gitignore"
108
136
  - ".rspec"
137
+ - ".rubocop.yml"
109
138
  - ".travis.yml"
110
139
  - Gemfile
111
140
  - Gemfile.lock