git-restart 0.0.6.pre.dev → 0.0.7dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/git-restart/runner.rb +24 -14
- data/lib/git-restart/task.rb +6 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef8189ec5b0c60dd0d7f4c0bc87f7723f9896d09
|
4
|
+
data.tar.gz: 58bc594f1edf63ef4f4ea23a3cb5f4325433f6e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec3fe1dd06650361126af62d93efab95bb30b9bfbe971c34be9c45332dbf8955e26f8e521df3b6fdb2b9784d4ee3c6e99b464a01592c47687caefa999f56f21b
|
7
|
+
data.tar.gz: 33fe46f6b69d6c534ad4ee362edd6c18b0665b5a606872efe3e78c9b13b70a90a58db9473cb254c02c105b6f805e7d8f13db53b3fea3906983f54116d8f3ba4d
|
data/lib/git-restart/runner.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
require 'mqtt/sub_handler'
|
3
|
+
|
3
4
|
require 'git'
|
5
|
+
require 'octokit'
|
4
6
|
|
5
7
|
require_relative "task.rb"
|
6
8
|
|
@@ -14,6 +16,7 @@ module GitRestart
|
|
14
16
|
attr_reader :current_task_file
|
15
17
|
|
16
18
|
attr_reader :mqtt
|
19
|
+
attr_accessor :octokit
|
17
20
|
|
18
21
|
def current_commit()
|
19
22
|
@git.object("HEAD^").sha;
|
@@ -41,15 +44,12 @@ module GitRestart
|
|
41
44
|
yield(self);
|
42
45
|
|
43
46
|
@listenedSub = @mqtt.subscribe_to "GitHub/#{@repo}" do |data|
|
44
|
-
puts "Received data: #{data}"
|
45
47
|
begin
|
46
48
|
data = JSON.parse(data, symbolize_names: true);
|
47
49
|
rescue
|
48
50
|
next;
|
49
51
|
end
|
50
52
|
|
51
|
-
puts "Processing data #{data}"
|
52
|
-
|
53
53
|
next unless data[:branch];
|
54
54
|
if(not @branches.empty?)
|
55
55
|
next unless @branches.include? data[:branch];
|
@@ -57,8 +57,6 @@ module GitRestart
|
|
57
57
|
next if @exclude_branches.include? data[:branch];
|
58
58
|
end
|
59
59
|
|
60
|
-
puts "Queueing data!"
|
61
|
-
|
62
60
|
@branchQueue << data;
|
63
61
|
end
|
64
62
|
|
@@ -67,6 +65,15 @@ module GitRestart
|
|
67
65
|
end
|
68
66
|
|
69
67
|
def update_status(name, newStatus, message = nil)
|
68
|
+
return unless @octokit;
|
69
|
+
|
70
|
+
begin
|
71
|
+
@octokit.create_status(@repo, current_commit, newStatus, {
|
72
|
+
context: "#{@name}/#{name}".gsub(" ", "_"),
|
73
|
+
description: message,
|
74
|
+
})
|
75
|
+
rescue
|
76
|
+
end
|
70
77
|
end
|
71
78
|
|
72
79
|
def _start_task_thread()
|
@@ -74,8 +81,6 @@ module GitRestart
|
|
74
81
|
loop do
|
75
82
|
newData = @branchQueue.pop;
|
76
83
|
|
77
|
-
puts "Popped data: #{newData}"
|
78
|
-
|
79
84
|
@current_modified = newData[:touched];
|
80
85
|
_switch_to(newData[:branch], newData[:head_commit]);
|
81
86
|
end
|
@@ -108,23 +113,24 @@ module GitRestart
|
|
108
113
|
t.gsub!(/^\.\//,"");
|
109
114
|
@current_task_file = t;
|
110
115
|
|
111
|
-
# TODO Add proper error reporting
|
112
116
|
begin
|
113
117
|
load(t);
|
114
118
|
rescue ScriptError, StandardError
|
119
|
+
update_status("File #{t}", :failure, "File could not be parsed!")
|
115
120
|
puts("File #{t} could not be loaded!");
|
116
121
|
rescue GitRestart::TaskValidityError
|
122
|
+
update_status("File #{t}", :failure, "Task-file not configured properly!")
|
117
123
|
puts("Task-File #{t} is not configured properly!");
|
118
124
|
end
|
119
125
|
end
|
120
126
|
|
121
|
-
puts "Finished loading! Next tasks
|
127
|
+
puts "Finished loading! Next tasks: #{@next_tasks.keys}"
|
122
128
|
end
|
123
129
|
|
124
130
|
def _start_next_tasks()
|
125
131
|
_generate_next_tasks();
|
126
132
|
|
127
|
-
puts "
|
133
|
+
puts "\n\nStarting next tasks!"
|
128
134
|
@next_tasks.each do |name, t|
|
129
135
|
next unless t.active;
|
130
136
|
next unless t.triggered?
|
@@ -135,8 +141,12 @@ module GitRestart
|
|
135
141
|
end
|
136
142
|
|
137
143
|
def _switch_to(branch, commit = nil)
|
138
|
-
puts "
|
139
|
-
|
144
|
+
puts "\nSwitching to branch: #{branch}#{commit ? ",commit: #{commit}" : ""}"
|
145
|
+
|
146
|
+
begin
|
147
|
+
@git.fetch();
|
148
|
+
rescue
|
149
|
+
end
|
140
150
|
|
141
151
|
if(branch != current_branch())
|
142
152
|
_stop_all_tasks();
|
@@ -144,10 +154,10 @@ module GitRestart
|
|
144
154
|
_stop_triggered_tasks();
|
145
155
|
end
|
146
156
|
@git.checkout(branch);
|
147
|
-
@git.reset_hard(commit);
|
148
|
-
|
149
157
|
@git.merge("origin/#{branch}");
|
150
158
|
|
159
|
+
@git.reset_hard(commit);
|
160
|
+
|
151
161
|
_start_next_tasks();
|
152
162
|
end
|
153
163
|
|
data/lib/git-restart/task.rb
CHANGED
@@ -111,8 +111,10 @@ module GitRestart
|
|
111
111
|
def start()
|
112
112
|
puts "Starting Task: #{@name}"
|
113
113
|
|
114
|
-
|
115
|
-
|
114
|
+
if @targets.empty?
|
115
|
+
_report_status(:success, "No tasks to run!");
|
116
|
+
return
|
117
|
+
end
|
116
118
|
|
117
119
|
@executionThread = Thread.new do
|
118
120
|
_report_status(:pending);
|
@@ -142,6 +144,8 @@ module GitRestart
|
|
142
144
|
end
|
143
145
|
end
|
144
146
|
@executionThread.abort_on_exception = true;
|
147
|
+
|
148
|
+
sleep 0.01
|
145
149
|
end
|
146
150
|
|
147
151
|
def stop()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-restart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7dev
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xasin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mqtt-sub_handler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
126
|
version: 1.3.1
|
113
127
|
requirements: []
|
114
128
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.5.2.1
|
116
130
|
signing_key:
|
117
131
|
specification_version: 4
|
118
132
|
summary: "(Re)start scripts and monitor them on a GitHub push"
|