git-semaphore 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e9733453309cb3c5b3e0b37c3caf3d4b3825cc28
4
- data.tar.gz: 0497c7bdfe034c178905e1603ef753285282cccf
2
+ SHA256:
3
+ metadata.gz: 04e832399e5dbfcb19a7e70ff162852ca8edde0207404024b85b9e6ba22f5993
4
+ data.tar.gz: 2254b33858b625230a9127793184c6e9dfecbf06afa1d2e696f4c473feae2f84
5
5
  SHA512:
6
- metadata.gz: da315dcce58237a6b00f3193338256445d6d4ae6698546c26380be02cf62636ebce7497b0252d20a2f0c31e491e9f3f4c6048789d71e789370155f7b97328865
7
- data.tar.gz: 5ad0d0af9c142e062db22e2bdc0469c47a38c26176458362051a79f00861017a35c4b6dc6782cf4ec2beebfce9b6a2b33657511bfea6947f626df1e466e3d2b9
6
+ metadata.gz: dbe85ef95117da76498f1c22b38b3b39a6eb65f6a5ab4484262758296571b4858c0719505c2043f65651f362041fdc20a093b2c55570456fcdae9f104f72b5ce
7
+ data.tar.gz: bafc84bdc4ab86b5b6182518a7c8b95e2e29bb4f1ddce28f84da160048002a28ce21e3bc4e8c97db6f38694634bd921e3ac00636332ab3871fd2f15c227d110e
data/.pryrc CHANGED
@@ -1,10 +1,16 @@
1
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ # this loads all of "git-semaphore"
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
2
4
  require 'git/semaphore'
3
5
 
4
6
  # utility function to set pry context
5
7
  # to an instance of <Rugged::Repository>
6
- def repository() pry Git::Semaphore.git_repo ; end
8
+ def repository
9
+ pry Git::Semaphore.git_repo
10
+ end
7
11
 
8
12
  # utility function to set pry context
9
13
  # to an instance of <Git::Semaphore::Project>
10
- def project() pry Git::Semaphore::Project.from_repo(Git::Semaphore.git_repo) ; end
14
+ def project
15
+ pry Git::Semaphore::Project.from_repo(Git::Semaphore.git_repo)
16
+ end
data/.rubocop.yml ADDED
@@ -0,0 +1,36 @@
1
+ Layout/EmptyLinesAroundBlockBody:
2
+ Enabled: false
3
+ Layout/EmptyLinesAroundClassBody:
4
+ Enabled: false
5
+ Layout/EmptyLinesAroundModuleBody:
6
+ Enabled: false
7
+ Layout/EmptyLineBetweenDefs:
8
+ Enabled: false
9
+ Layout/MultilineOperationIndentation:
10
+ Enabled: false
11
+
12
+ Metrics/AbcSize:
13
+ Enabled: false
14
+ Metrics/ClassLength:
15
+ Enabled: false
16
+ Metrics/LineLength:
17
+ Enabled: false
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Style/Alias:
22
+ Enabled: false
23
+ Style/BlockDelimiters:
24
+ Enabled: false
25
+ Style/Documentation:
26
+ Enabled: false
27
+ Style/EmptyCaseCondition:
28
+ Enabled: false
29
+ Style/FrozenStringLiteralComment:
30
+ Enabled: false
31
+ Style/SingleLineMethods:
32
+ Enabled: false
33
+ Style/TrailingCommaInLiteral:
34
+ Enabled: false
35
+ Style/TrailingCommaInArguments:
36
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.5.1
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
3
5
  # Specify your gem's dependencies in git-semaphore.gemspec
4
6
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2012-2016 Peter Vandenberk
3
+ Copyright (c) 2012-2018 Peter Vandenberk
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -1,19 +1,33 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # rubocop:disable Style/SymbolArray
2
+ # rubocop:disable Style/HashSyntax
3
3
 
4
- task :default => :test
4
+ require 'bundler/gem_tasks'
5
5
 
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList['test/**/*_test.rb']
6
+ task :validate_gemspec do
7
+ Bundler.load_gemspec('git-semaphore.gemspec').validate
10
8
  end
11
9
 
12
- task :gemspec do
13
- @gemspec ||= eval(File.read(Dir["*.gemspec"].first))
10
+ task :version => :validate_gemspec do
11
+ puts Git::Semaphore::VERSION
14
12
  end
15
13
 
16
- desc "Validate the gemspec"
17
- task :validate => :gemspec do
18
- @gemspec.validate
14
+ require 'rubocop/rake_task'
15
+
16
+ RuboCop::RakeTask.new(:rubocop)
17
+
18
+ require 'rake/testtask'
19
+
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'test'
22
+ t.libs << 'lib'
23
+ t.test_files = FileList['test/**/*_test.rb']
19
24
  end
25
+
26
+ task :default => [:rubocop, :test]
27
+
28
+ task :documentation
29
+
30
+ Rake::Task['build'].enhance([:default, :documentation])
31
+
32
+ # rubocop:enable Style/HashSyntax
33
+ # rubocop:enable Style/SymbolArray
data/bin/console CHANGED
@@ -1,14 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "git/semaphore"
3
+ require 'bundler/setup'
4
+ require 'git/semaphore'
5
5
 
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- require "pry"
6
+ require 'pry'
11
7
  Pry.start
12
8
 
13
- # require "irb"
14
- # IRB.start
9
+ # That's all Folks!
data/bin/setup CHANGED
@@ -4,7 +4,10 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  rbenv install -s
7
- gem install bundler
7
+ gem install --conservative bundler
8
8
  bundle install
9
9
 
10
+ set +vxeu
11
+ echo
12
+
10
13
  # That's all Folks!
data/exe/git-semaphore CHANGED
@@ -1,97 +1,96 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'git/semaphore'
5
6
 
6
7
  require 'slop'
7
8
 
8
- options = Slop.parse(help: true) do
9
+ options = Slop.parse(help: true) do |o|
9
10
 
10
- on :version, 'Print the version' do
11
- puts Git::Semaphore::COPYRIGHT
11
+ o.banner = <<~"BANNER"
12
+ Usage: git-semaphore [options]
13
+
14
+ v#{Git::Semaphore::VERSION}
15
+
16
+ Options:
17
+ BANNER
18
+
19
+ o.on '--version', 'Print the version' do
20
+ puts Git::Semaphore::LONG_VERSION
12
21
  exit(0)
13
22
  end
14
23
 
15
- banner Git::Semaphore::BANNER
16
-
17
- on :settings, 'Display most relevant settings'
18
- on :internals, 'Display all internal settings'
24
+ o.on '--help', 'Print help message' do
25
+ puts o
26
+ exit(0)
27
+ end
19
28
 
20
- on :browse, 'Open the project on https://semaphoreci.com/'
29
+ o.on '--refresh', 'Bypass cached information and refresh from API'
21
30
 
22
- on :clean, 'Deletes the cached API query results'
31
+ o.on '--projects', 'List all projects and their current status'
23
32
 
24
- on :projects, 'List all projects and their current status'
25
- on :branches, 'List all branches for the current project'
26
- on :status, 'List the build status for the current branch'
27
- on :history, 'List the build history for the current branch'
28
- on :information, 'List the commit information for the last build'
29
- on :log, 'List the build log for the last build'
30
- on :rebuild, 'Rebuild last revision for the current branch'
33
+ o.on '--browse', 'Open the project on https://semaphoreci.com/'
34
+ o.on '--rebuild', 'Rebuild last revision for the current branch'
31
35
 
32
- end
36
+ o.on '--settings', 'Display most relevant settings'
37
+ o.on '--internals', 'Display all internal settings'
33
38
 
34
- if options.clean?
35
- Git::Semaphore.empty_cache_dir
36
- exit 0
37
- end
39
+ o.on '--branches', 'List all branches for the current project'
40
+ o.on '--status', 'List the build status for the current branch'
41
+ o.on '--history', 'List the build history for the current branch'
42
+ o.on '--information', 'List the commit information for the last build'
43
+ o.on '--log', 'List the build log for the last build'
38
44
 
39
- if options.projects?
40
- puts Git::Semaphore::Project.all.to_json
41
- exit 0
42
45
  end
43
46
 
44
47
  project = if (git_repo = Git::Semaphore.git_repo)
45
- Git::Semaphore::Project.from_repo(git_repo)
46
- else
47
- Git::Semaphore::Project.from_config(ENV)
48
- end
48
+ Git::Semaphore::Project.from_repo(git_repo)
49
+ else
50
+ Git::Semaphore::Project.from_config(ENV)
51
+ end
49
52
 
50
- if options.settings?
51
- puts project.settings.to_json
52
- exit 0
53
- end
53
+ class SafeProject
54
+ # rubocop:disable Style/MethodMissing
54
55
 
55
- if options.internals?
56
- puts project.internals.to_json
57
- exit 0
58
- end
56
+ def initialize(project)
57
+ @project = project
58
+ end
59
59
 
60
- if options.browse?
61
- `open #{project.branch_url}`
62
- exit 0
63
- end
60
+ def method_missing(name, *args, &block)
61
+ if @project.exist?
62
+ @project.send(name, *args, &block)
63
+ else
64
+ { error: "Project #{@project.full_name} doesn't exist on semaphoreci.com" }
65
+ end
66
+ end
64
67
 
65
- if options.branches?
66
- puts project.branches.to_json
67
- exit 0
68
- end
68
+ def respond_to?(name, include_all = false)
69
+ @project.respond_to? name, include_all
70
+ end
69
71
 
70
- if options.status?
71
- puts project.status.to_json
72
- exit 0
72
+ # rubocop:enable Style/MethodMissing
73
73
  end
74
74
 
75
- if options.history?
76
- puts project.history.to_json
77
- exit 0
78
- end
75
+ project = SafeProject.new(project)
76
+ refresh = options.refresh?
79
77
 
80
- if options.information?
81
- puts project.information.to_json
82
- exit 0
83
- end
78
+ case
79
+ when options.projects? then puts Git::Semaphore::Project.all(refresh).to_json
84
80
 
85
- if options.log?
86
- puts project.log.to_json
87
- exit 0
88
- end
81
+ when options.browse? then puts project.browse.to_json
82
+ when options.rebuild? then puts project.rebuild.to_json
89
83
 
90
- if options.rebuild?
91
- puts project.rebuild
92
- exit 0
93
- end
84
+ when options.settings? then puts project.settings.to_json
85
+ when options.internals? then puts project.internals.to_json
94
86
 
95
- fail "Coming soon!"
87
+ when options.branches? then puts project.branches(refresh).to_json
88
+ when options.status? then puts project.status(refresh).to_json
89
+ when options.history? then puts project.history(refresh).to_json
90
+ when options.information? then puts project.information(refresh).to_json
91
+ when options.log? then puts project.log(refresh).to_json
92
+ else
93
+ puts options
94
+ end
96
95
 
97
96
  # That's all Folks!
@@ -1,31 +1,34 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'git/semaphore/version'
4
+ require 'git/semaphore/gemspec'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "git-semaphore"
7
+ spec.name = Git::Semaphore::NAME
8
8
  spec.version = Git::Semaphore::VERSION
9
- spec.authors = ["Peter Vandenberk"]
10
- spec.email = ["pvandenberk@mac.com"]
9
+ spec.authors = ['Peter Vandenberk']
10
+ spec.email = ['pvandenberk@mac.com']
11
11
 
12
- spec.summary = %q{git integration with semaphoreci.com}
13
- spec.description = %q{command-line integration with semaphoreci.com for git repositories}
14
- spec.homepage = "https://github.com/pvdb/git-semaphore"
15
- spec.license = "MIT"
12
+ spec.summary = 'git integration with semaphoreci.com'
13
+ spec.description = 'command-line integration with semaphoreci.com for git repositories'
14
+ spec.homepage = 'https://github.com/pvdb/git-semaphore'
15
+ spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
17
+ spec.files = begin
18
+ `git ls-files -z`
19
+ .split("\x0")
20
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
19
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
21
25
 
22
- spec.add_dependency "slop", "~> 3.0"
23
- spec.add_dependency "rugged" , "~> 0.24"
26
+ spec.post_install_message = Git::Semaphore::PIM
24
27
 
25
- spec.add_development_dependency "bundler", "~> 1.12"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "minitest", "~> 5.0"
28
+ spec.add_dependency 'rugged', '~> 0.27'
29
+ spec.add_dependency 'slop', '~> 4.6'
28
30
 
29
- spec.add_development_dependency "pry"
30
- spec.add_development_dependency "pry-rescue"
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'rake'
31
34
  end
data/lib/git/semaphore.rb CHANGED
@@ -1,16 +1,19 @@
1
1
  require 'uri'
2
2
  require 'date'
3
3
  require 'json'
4
+ require 'time'
4
5
  require 'openssl'
5
6
  require 'net/http'
6
7
  require 'fileutils'
7
8
 
8
9
  require 'rugged'
9
10
 
10
- class Rugged::Repository
11
- def owner() File.basename(File.dirname(workdir)) ; end
12
- def name() File.basename(workdir) ; end
13
- def full_name() "#{owner}/#{name}" ; end
11
+ module Rugged
12
+ class Repository
13
+ def owner() File.basename(File.dirname(workdir)); end
14
+ def name() File.basename(workdir); end
15
+ def full_name() "#{owner}/#{name}"; end
16
+ end
14
17
  end
15
18
 
16
19
  module Git
@@ -24,24 +27,24 @@ module Git
24
27
 
25
28
  def self.cache_dir
26
29
  @cache_dir ||= begin
27
- File.join(self.home_dir, '.git', 'semaphore').tap do |cache_dir|
30
+ File.join(home_dir, '.git', 'semaphore').tap do |cache_dir|
28
31
  FileUtils.mkdir_p(cache_dir)
29
32
  end
30
33
  end
31
34
  end
32
35
 
33
- def self.cache_dir_for identifier
34
- File.join(self.cache_dir, identifier).tap do |cache_dir|
36
+ def self.cache_dir_for(identifier)
37
+ File.join(cache_dir, identifier).tap do |cache_dir|
35
38
  FileUtils.mkdir_p(cache_dir)
36
39
  end
37
40
  end
38
41
 
39
42
  def self.empty_cache_dir
40
- FileUtils.rm_r Dir.glob(File.join(self.cache_dir, '*'))
43
+ FileUtils.rm_r Dir.glob(File.join(cache_dir, '*'))
41
44
  end
42
45
 
43
- def self.from_json_cache path
44
- if File.exists? path
46
+ def self.from_json_cache(path, refresh = false)
47
+ if !refresh && File.exist?(path)
45
48
  JSON.parse(File.read(path))
46
49
  else
47
50
  yield.tap do |content|
@@ -51,31 +54,31 @@ module Git
51
54
  end
52
55
 
53
56
  def self.git_repo
54
- begin
55
- Rugged::Repository.new(Dir.pwd)
56
- rescue Rugged::RepositoryError
57
- nil
58
- end
57
+ Rugged::Repository.new(Dir.pwd)
58
+ rescue Rugged::RepositoryError
59
+ nil
59
60
  end
60
61
 
61
62
  def self.env_auth_token
62
63
  @env_auth_token ||= ENV['SEMAPHORE_AUTH_TOKEN']
63
64
  end
64
65
 
66
+ def self.global_auth_token
67
+ Rugged::Config.global['semaphore.authtoken']
68
+ end
69
+
65
70
  def self.git_auth_token
66
- git_repo && git_repo.config['semaphore.authtoken']
71
+ git_repo&.config&.get('semaphore.authtoken')
67
72
  end
68
73
 
69
74
  def self.auth_token
70
- git_auth_token || env_auth_token
75
+ git_auth_token || global_auth_token || env_auth_token
71
76
  end
72
77
 
73
78
  end
74
79
  end
75
80
 
76
81
  require 'git/semaphore/version'
77
- require 'git/semaphore/banner'
78
- require 'git/semaphore/copyright'
79
82
 
80
83
  require 'git/semaphore/api'
81
84
  require 'git/semaphore/api_cache'