spectre-git 0.2.1 → 2.0.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 +4 -4
- data/lib/spectre/git.rb +170 -179
- metadata +27 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 601d03616fada342e6d886e5d257be8b6909d7e0b29a3b5d413cf6164b5a605c
|
|
4
|
+
data.tar.gz: 7c2a0892ef5543f0191ff351bedc62d16c9d92daf38c5a0445fecaf28683a850
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e1d9ff166fcb1b3a95d98f2ff7c46f9bb95e201da4a4ae1f17b3a0bbfbec4c09b0b3c0c49b8660bb728a1a9360e51b489ed3b5c4d2386868a9d7d79d4f8615b
|
|
7
|
+
data.tar.gz: 4d5903bca250a0f7e86ef39e4ac24673bfcfb2794df7f51602e2554e56085c8595ebe6fa11e4d1fa325a0afa0069b789c4869a034fc9f8c95c64c7349024770d
|
data/lib/spectre/git.rb
CHANGED
|
@@ -1,179 +1,170 @@
|
|
|
1
|
-
require 'open3'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
require 'logger'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def initialize cfg, logger
|
|
11
|
-
@__logger = logger
|
|
12
|
-
@__cfg = cfg
|
|
13
|
-
@__repo_path = nil
|
|
14
|
-
|
|
15
|
-
url(@__cfg['url'])
|
|
16
|
-
@__cfg['branch'] = 'master' unless @__cfg['branch']
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def url git_url
|
|
20
|
-
url_match = git_url
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@__cfg['
|
|
26
|
-
@__cfg['
|
|
27
|
-
@__cfg['
|
|
28
|
-
@__cfg['
|
|
29
|
-
@__cfg['
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@__cfg['working_dir']
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
clone_cmd
|
|
66
|
-
clone_cmd <<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
clone_cmd <<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
clone_cmd <<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
error
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
config['git'].each do |name, cfg|
|
|
172
|
-
@@cfg[name] = cfg
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
Spectre.delegate :git, to: self
|
|
178
|
-
end
|
|
179
|
-
end
|
|
1
|
+
require 'open3'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'logger'
|
|
4
|
+
|
|
5
|
+
module Spectre
|
|
6
|
+
module Git
|
|
7
|
+
class GitAccess
|
|
8
|
+
include Spectre::Delegate if defined? Spectre::Delegate
|
|
9
|
+
|
|
10
|
+
def initialize cfg, logger
|
|
11
|
+
@__logger = logger
|
|
12
|
+
@__cfg = cfg
|
|
13
|
+
@__repo_path = nil
|
|
14
|
+
|
|
15
|
+
url(@__cfg['url'])
|
|
16
|
+
@__cfg['branch'] = 'master' unless @__cfg['branch']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def url git_url
|
|
20
|
+
url_match = git_url
|
|
21
|
+
.match(%r{^(?<scheme>http(?:s)?)://(?:(?<user>[^/:]*):(?<pass>.*)@)?(?<url>.*/(?<name>[^/]*)\.git)$})
|
|
22
|
+
|
|
23
|
+
raise "invalid git url: '#{git_url}'" unless url_match
|
|
24
|
+
|
|
25
|
+
@__cfg['url_path'] = url_match[:url]
|
|
26
|
+
@__cfg['scheme'] = url_match[:scheme]
|
|
27
|
+
@__cfg['username'] = url_match[:user] unless @__cfg['username']
|
|
28
|
+
@__cfg['password'] = url_match[:pass] unless @__cfg['password']
|
|
29
|
+
@__cfg['name'] = url_match[:name] unless @__cfg['name']
|
|
30
|
+
@__cfg['working_dir'] = './tmp' unless @__cfg['working_dir']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def username user
|
|
34
|
+
@__cfg['username'] = user
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def password pass
|
|
38
|
+
@__cfg['password'] = pass
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def working_dir path
|
|
42
|
+
@__cfg['working_dir'] = path if path
|
|
43
|
+
@__cfg['working_dir']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def cert file_path
|
|
47
|
+
@__cfg['cert'] = file_path
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def branch name
|
|
51
|
+
@__cfg['branch'] = name
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def clone
|
|
55
|
+
@__repo_path = File.absolute_path File.join(@__cfg['working_dir'], @__cfg['name'])
|
|
56
|
+
|
|
57
|
+
if File.exist? @__repo_path
|
|
58
|
+
FileUtils.rm_rf(@__repo_path)
|
|
59
|
+
@__logger.debug("repo path '#{@__repo_path}' removed")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
FileUtils.mkpath(@__repo_path)
|
|
63
|
+
@__logger.debug("repo path '#{@__repo_path}' created")
|
|
64
|
+
|
|
65
|
+
clone_cmd = ['git', 'clone']
|
|
66
|
+
clone_cmd << '--branch'
|
|
67
|
+
clone_cmd << @__cfg['branch']
|
|
68
|
+
|
|
69
|
+
if @__cfg['cert']
|
|
70
|
+
clone_cmd << '--config'
|
|
71
|
+
clone_cmd << "http.sslCAInfo=#{@__cfg['cert']}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
clone_cmd << build_url
|
|
75
|
+
clone_cmd << @__repo_path
|
|
76
|
+
|
|
77
|
+
clone_cmd = clone_cmd.join(' ')
|
|
78
|
+
|
|
79
|
+
@__logger.info(clone_cmd.gsub(%r{:([^\:\@/]*)@}, ':*****@').to_s)
|
|
80
|
+
|
|
81
|
+
run(clone_cmd, log: false)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def add path
|
|
85
|
+
run("git add \"#{path}\"")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def add_all
|
|
89
|
+
run('git add --all')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def tag name, message: nil
|
|
93
|
+
run("git tag -a -m \"#{message}\" \"#{name}\"")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def commit message
|
|
97
|
+
run("git commit -m \"#{message}\"")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def push
|
|
101
|
+
run('git push')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def pull
|
|
105
|
+
run('git pull')
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def write_file path, content
|
|
109
|
+
full_path = File.join(@__repo_path, path)
|
|
110
|
+
|
|
111
|
+
file = File.open(full_path, 'w')
|
|
112
|
+
file.write(content)
|
|
113
|
+
file.close
|
|
114
|
+
|
|
115
|
+
full_path
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def read_file path
|
|
119
|
+
full_path = File.join(@__repo_path, path)
|
|
120
|
+
File.read(full_path)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def cleanup
|
|
124
|
+
FileUtils.rm_rf(@__repo_path)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def run cmd, log: true
|
|
128
|
+
_stdin, stdout, stderr, wait_thr = Open3.popen3(cmd, chdir: @__repo_path)
|
|
129
|
+
|
|
130
|
+
@__logger.info(cmd) if log
|
|
131
|
+
|
|
132
|
+
_output = stdout.gets(nil)
|
|
133
|
+
stdout.close
|
|
134
|
+
|
|
135
|
+
error = stderr.gets(nil)
|
|
136
|
+
stderr.close
|
|
137
|
+
|
|
138
|
+
raise error unless wait_thr.value.exitstatus.zero?
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
private
|
|
142
|
+
|
|
143
|
+
def build_url
|
|
144
|
+
cred = @__cfg['username'] ? "#{@__cfg['username']}:#{@__cfg['password']}@" : ''
|
|
145
|
+
"#{@__cfg['scheme']}://#{cred}#{@__cfg['url_path']}"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
class Client
|
|
150
|
+
include Spectre::Delegate if defined? Spectre::Delegate
|
|
151
|
+
|
|
152
|
+
def initialize config, logger
|
|
153
|
+
@config = config['git'] || {}
|
|
154
|
+
@logger = logger
|
|
155
|
+
@last_access = nil
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def git(name = nil, &)
|
|
159
|
+
config = @config[name] || {}
|
|
160
|
+
|
|
161
|
+
config['url'] = name unless config['url']
|
|
162
|
+
|
|
163
|
+
@last_access = GitAccess.new(config, @logger) if name
|
|
164
|
+
@last_access.instance_eval(&)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
Engine.register(Git::Client, :git) if defined? Engine
|
|
170
|
+
end
|
metadata
CHANGED
|
@@ -1,46 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spectre-git
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Neubauer
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2025-03-21 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: logger
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: '0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: stringio
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
27
40
|
description: Adds basic git commands to the spectre framework
|
|
28
41
|
email:
|
|
29
|
-
-
|
|
42
|
+
- christian.neubauer@ionos.com
|
|
30
43
|
executables: []
|
|
31
44
|
extensions: []
|
|
32
45
|
extra_rdoc_files: []
|
|
33
46
|
files:
|
|
34
47
|
- lib/spectre/git.rb
|
|
35
|
-
homepage: https://github.com/
|
|
48
|
+
homepage: https://github.com/ionos-spectre/spectre-git
|
|
36
49
|
licenses:
|
|
37
|
-
-
|
|
50
|
+
- GPL-3.0-or-later
|
|
38
51
|
metadata:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
changelog_uri: https://github.com/cneubauer/spectre-git/blob/master/CHANGELOG.md
|
|
43
|
-
post_install_message:
|
|
52
|
+
homepage_uri: https://github.com/ionos-spectre/spectre-git
|
|
53
|
+
source_code_uri: https://github.com/ionos-spectre/spectre-git
|
|
54
|
+
changelog_uri: https://github.com/ionos-spectre/spectre-git/blob/master/CHANGELOG.md
|
|
44
55
|
rdoc_options: []
|
|
45
56
|
require_paths:
|
|
46
57
|
- lib
|
|
@@ -48,15 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
48
59
|
requirements:
|
|
49
60
|
- - ">="
|
|
50
61
|
- !ruby/object:Gem::Version
|
|
51
|
-
version:
|
|
62
|
+
version: '3.4'
|
|
52
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
64
|
requirements:
|
|
54
65
|
- - ">="
|
|
55
66
|
- !ruby/object:Gem::Version
|
|
56
67
|
version: '0'
|
|
57
68
|
requirements: []
|
|
58
|
-
rubygems_version: 3.
|
|
59
|
-
signing_key:
|
|
69
|
+
rubygems_version: 3.6.6
|
|
60
70
|
specification_version: 4
|
|
61
71
|
summary: Git module for spectre
|
|
62
72
|
test_files: []
|