git-semaphore 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.pryrc +9 -3
- data/.rubocop.yml +36 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +26 -12
- data/bin/console +4 -9
- data/bin/setup +4 -1
- data/exe/git-semaphore +64 -65
- data/git-semaphore.gemspec +22 -19
- data/lib/git/semaphore.rb +22 -19
- data/lib/git/semaphore/api.rb +29 -27
- data/lib/git/semaphore/api_cache.rb +17 -17
- data/lib/git/semaphore/api_enrich.rb +10 -10
- data/lib/git/semaphore/gemspec.rb +13 -0
- data/lib/git/semaphore/project.rb +187 -174
- data/lib/git/semaphore/version.rb +11 -1
- metadata +19 -46
- data/Guardfile +0 -15
- data/lib/git/semaphore/banner.rb +0 -13
- data/lib/git/semaphore/copyright.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 04e832399e5dbfcb19a7e70ff162852ca8edde0207404024b85b9e6ba22f5993
|
4
|
+
data.tar.gz: 2254b33858b625230a9127793184c6e9dfecbf06afa1d2e696f4c473feae2f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe85ef95117da76498f1c22b38b3b39a6eb65f6a5ab4484262758296571b4858c0719505c2043f65651f362041fdc20a093b2c55570456fcdae9f104f72b5ce
|
7
|
+
data.tar.gz: bafc84bdc4ab86b5b6182518a7c8b95e2e29bb4f1ddce28f84da160048002a28ce21e3bc4e8c97db6f38694634bd921e3ac00636332ab3871fd2f15c227d110e
|
data/.pryrc
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
|
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
|
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
|
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.
|
1
|
+
2.5.1
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2012-
|
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
|
-
|
2
|
-
|
1
|
+
# rubocop:disable Style/SymbolArray
|
2
|
+
# rubocop:disable Style/HashSyntax
|
3
3
|
|
4
|
-
|
4
|
+
require 'bundler/gem_tasks'
|
5
5
|
|
6
|
-
|
7
|
-
|
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 :
|
13
|
-
|
10
|
+
task :version => :validate_gemspec do
|
11
|
+
puts Git::Semaphore::VERSION
|
14
12
|
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'git/semaphore'
|
5
5
|
|
6
|
-
|
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
|
-
#
|
14
|
-
# IRB.start
|
9
|
+
# That's all Folks!
|
data/bin/setup
CHANGED
data/exe/git-semaphore
CHANGED
@@ -1,97 +1,96 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
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
|
-
|
11
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
24
|
+
o.on '--help', 'Print help message' do
|
25
|
+
puts o
|
26
|
+
exit(0)
|
27
|
+
end
|
19
28
|
|
20
|
-
on
|
29
|
+
o.on '--refresh', 'Bypass cached information and refresh from API'
|
21
30
|
|
22
|
-
on
|
31
|
+
o.on '--projects', 'List all projects and their current status'
|
23
32
|
|
24
|
-
on
|
25
|
-
on
|
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
|
-
|
36
|
+
o.on '--settings', 'Display most relevant settings'
|
37
|
+
o.on '--internals', 'Display all internal settings'
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
46
|
-
else
|
47
|
-
|
48
|
-
end
|
48
|
+
Git::Semaphore::Project.from_repo(git_repo)
|
49
|
+
else
|
50
|
+
Git::Semaphore::Project.from_config(ENV)
|
51
|
+
end
|
49
52
|
|
50
|
-
|
51
|
-
|
52
|
-
exit 0
|
53
|
-
end
|
53
|
+
class SafeProject
|
54
|
+
# rubocop:disable Style/MethodMissing
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
56
|
+
def initialize(project)
|
57
|
+
@project = project
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
68
|
+
def respond_to?(name, include_all = false)
|
69
|
+
@project.respond_to? name, include_all
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
puts project.status.to_json
|
72
|
-
exit 0
|
72
|
+
# rubocop:enable Style/MethodMissing
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
exit 0
|
78
|
-
end
|
75
|
+
project = SafeProject.new(project)
|
76
|
+
refresh = options.refresh?
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
exit 0
|
83
|
-
end
|
78
|
+
case
|
79
|
+
when options.projects? then puts Git::Semaphore::Project.all(refresh).to_json
|
84
80
|
|
85
|
-
|
86
|
-
|
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
|
-
|
91
|
-
|
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
|
-
|
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!
|
data/git-semaphore.gemspec
CHANGED
@@ -1,31 +1,34 @@
|
|
1
|
-
|
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 =
|
7
|
+
spec.name = Git::Semaphore::NAME
|
8
8
|
spec.version = Git::Semaphore::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Peter Vandenberk']
|
10
|
+
spec.email = ['pvandenberk@mac.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
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 =
|
18
|
-
|
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 = [
|
24
|
+
spec.require_paths = ['lib']
|
21
25
|
|
22
|
-
spec.
|
23
|
-
spec.add_dependency "rugged" , "~> 0.24"
|
26
|
+
spec.post_install_message = Git::Semaphore::PIM
|
24
27
|
|
25
|
-
spec.
|
26
|
-
spec.
|
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
|
30
|
-
spec.add_development_dependency
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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(
|
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
|
34
|
-
File.join(
|
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(
|
43
|
+
FileUtils.rm_r Dir.glob(File.join(cache_dir, '*'))
|
41
44
|
end
|
42
45
|
|
43
|
-
def self.from_json_cache
|
44
|
-
if File.
|
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
|
-
|
55
|
-
|
56
|
-
|
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
|
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'
|