coderunner 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/coderunner.gemspec +3 -3
- data/lib/coderunner/repository.rb +86 -2
- data/lib/coderunner/repository_manager.rb +34 -22
- data/test/test_coderunnerrepo.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4523bd885a2ccf5d75df6caf448f0a70e2e1ded
|
4
|
+
data.tar.gz: 6b7bb1c1c707ceb8ab64638a837a4fab4c4aa39a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688cacb761e7a040fbc956ed09c4615adf5648b995613b697f2f89e98842f7c683d5bffa8a926ae3e33c09ff592a8b89787861ad657073a462c6aff77f85edba
|
7
|
+
data.tar.gz: b64b6c69f683c408a3d12ec38031ae46388b31ba436bc47d99470fc1d5115cc1b192b49791d718d6b977f5aecf43d847f49dc4e914002c6d98df581b402dd79b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.16.
|
1
|
+
0.16.2
|
data/coderunner.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: coderunner 0.16.
|
5
|
+
# stub: coderunner 0.16.2 ruby lib
|
6
6
|
# stub: ext/extconf.rb
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "coderunner"
|
10
|
-
s.version = "0.16.
|
10
|
+
s.version = "0.16.2"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.authors = ["Edmund Highcock"]
|
15
|
-
s.date = "2015-05-
|
15
|
+
s.date = "2015-05-17"
|
16
16
|
s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
|
17
17
|
s.email = "edmundhighcock@sourceforge.net"
|
18
18
|
s.executables = ["coderunner"]
|
@@ -24,7 +24,29 @@ class CodeRunner
|
|
24
24
|
# slightly customised git repository. It contains
|
25
25
|
# methods for initializing standard files, and maintains
|
26
26
|
# a small amount of metadata about the repository.
|
27
|
+
# In addition, every clone of coderunner repository
|
28
|
+
# comes in a pair: one bare repository, and one local
|
29
|
+
# repository, which is a clone of the bare repository.
|
30
|
+
# This allows easy synchronisation of working directories
|
31
|
+
# without the need for a central server which all
|
32
|
+
# working directories have access to.
|
27
33
|
class Repository < Git::Base
|
34
|
+
# Create a coderunner repo, which consists of a
|
35
|
+
# twin set of a bare repo and a clone of that
|
36
|
+
# repo. folder must end in '.git'
|
37
|
+
#
|
38
|
+
def self.init(folder)
|
39
|
+
if folder =~ /\.git$/
|
40
|
+
raise "Please do not add '.git' to the end of #{folder}. Two repositories will be created: a bare repo ending in .git and a clone of this bare repo"
|
41
|
+
end
|
42
|
+
super(folder + '.git', bare: true)
|
43
|
+
repo = clone(folder + '.git', folder)
|
44
|
+
repo.init_metadata
|
45
|
+
repo.init_readme
|
46
|
+
repo.init_defaults_folder
|
47
|
+
p 'remotes', repo.remotes.map{|r| r.name}
|
48
|
+
repo.simple_push(repo.remote("origin"))
|
49
|
+
end
|
28
50
|
# If the folder is within a coderunner repository
|
29
51
|
# return the root folder of the repository; else
|
30
52
|
# return nil
|
@@ -34,7 +56,7 @@ class CodeRunner
|
|
34
56
|
Dir.entries(f2).include?('.code_runner_repo_metadata'))
|
35
57
|
f2 = File.expand_path(f2 + '/..')
|
36
58
|
(f2=nil; break) if f2 == '/'
|
37
|
-
p 'f2 is ', f2
|
59
|
+
#p 'f2 is ', f2
|
38
60
|
end
|
39
61
|
return f2
|
40
62
|
end
|
@@ -46,6 +68,11 @@ class CodeRunner
|
|
46
68
|
raise "#{folder} is not a coderunner repository " if not f2
|
47
69
|
return open(f2)
|
48
70
|
end
|
71
|
+
# Returns a Git::Base object referring to the bare twin
|
72
|
+
# repository.
|
73
|
+
def bare_repo
|
74
|
+
@bare_repo ||= Git::Base.open(dir.to_s + '.git')
|
75
|
+
end
|
49
76
|
def relative_path(folder=Dir.pwd)
|
50
77
|
File.expand_path(folder).sub(File.expand_path(dir.to_s) + '/', '')
|
51
78
|
end
|
@@ -125,7 +152,7 @@ Created on: #{Time.now.to_s}
|
|
125
152
|
EOF
|
126
153
|
end
|
127
154
|
def split_url(remote_name)
|
128
|
-
remote(remote_name).url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
155
|
+
bare_repo.remote(remote_name).url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
129
156
|
namehost = $~[:namehost]
|
130
157
|
folder = $~[:folder]
|
131
158
|
return [namehost, folder]
|
@@ -181,6 +208,63 @@ EOF
|
|
181
208
|
puts string
|
182
209
|
system string
|
183
210
|
end
|
211
|
+
|
212
|
+
def add_remote(name, url)
|
213
|
+
url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
214
|
+
barefolder = $~[:folder]
|
215
|
+
unless barefolder =~ /\.git$/
|
216
|
+
raise "All remotes must end in .git for coderunnerrepo"
|
217
|
+
end
|
218
|
+
super(name, url)
|
219
|
+
end
|
220
|
+
|
221
|
+
alias :simple_pull :pull
|
222
|
+
|
223
|
+
# Pull from the given remote object. remote must be a remote
|
224
|
+
# object from the twin bare repo, i.e. a member of bare_repo.remotes
|
225
|
+
# NOT a remote from the coderunner repo (which only ever has
|
226
|
+
# one remote: origin, corresponding to the bare repo).
|
227
|
+
def pull(remote)
|
228
|
+
remote.url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
229
|
+
namehost = $~[:namehost]
|
230
|
+
folder = $~[:folder]
|
231
|
+
barefolder = folder + '.git'
|
232
|
+
p namehost, barefolder
|
233
|
+
if folder =~ /\.git$/
|
234
|
+
raise "Remotes must not end in .git for coderunnerrepo"
|
235
|
+
end
|
236
|
+
try_system %[ssh #{namehost} "cd #{folder} && git push origin"]
|
237
|
+
bare_repo.pull(remote)
|
238
|
+
simple_pull(remote('origin'))
|
239
|
+
end
|
240
|
+
# A simple git push... does not try to push to local
|
241
|
+
# bare repo or pull remote working repos
|
242
|
+
alias :simple_push :push
|
243
|
+
|
244
|
+
# Push to the given remote object. remote must be a remote
|
245
|
+
# object from the twin bare repo, i.e. a member of bare_repo.remotes
|
246
|
+
# NOT a remote from the coderunner repo (which only ever has
|
247
|
+
# one remote: origin, corresponding to the bare repo).
|
248
|
+
#
|
249
|
+
# First push to the bare '.git' twin repo, then push that
|
250
|
+
# bare repo to the remote, then pull remote repos from the
|
251
|
+
# remote bare repos.
|
252
|
+
def push(remote)
|
253
|
+
remote.url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
254
|
+
namehost = $~[:namehost]
|
255
|
+
folder = $~[:folder]
|
256
|
+
barefolder = folder + '.git'
|
257
|
+
p namehost, barefolder
|
258
|
+
if folder =~ /\.git$/
|
259
|
+
raise "Remotes must not end in .git for coderunnerrepo"
|
260
|
+
end
|
261
|
+
simple_push(remote('origin'))
|
262
|
+
bare_repo.push(remote)
|
263
|
+
try_system %[ssh #{namehost} "cd #{folder} && git pull origin"]
|
264
|
+
end
|
265
|
+
def try_system(str)
|
266
|
+
RepositoryManager.try_system(str)
|
267
|
+
end
|
184
268
|
end
|
185
269
|
|
186
270
|
end
|
@@ -50,7 +50,7 @@ EXAMPLES
|
|
50
50
|
EOF
|
51
51
|
|
52
52
|
COMMANDS_WITH_HELP = [
|
53
|
-
['add_remote', 'adrm', 2, 'Add a remote url to the repository.', ['name', 'url'], [:Y]],
|
53
|
+
['add_remote', 'adrm', 2, 'Add a remote url to the repository. The url must not end in \'.git\'', ['name', 'url'], [:Y]],
|
54
54
|
['add_folder', 'add', 1, 'Add the folder to the repository... this adds the directory tree and all coderunner data files to the repository, e.g. .code_runner_info.rb, script defaults, command histories etc. Note that this command must be issued in the root of the repository, or with the -Y flag giving the root of the repository.', ['folder'], [:Y]],
|
55
55
|
['init_repository', 'init', 1, 'Create a new repository with the given name.', ['name'], []],
|
56
56
|
['pull_repository', 'pull', 2, 'Pull repository from all remotes, or from a comma-separated list of remotes given by the -r option.', ['name', 'url'], [:r, :Y]],
|
@@ -114,43 +114,55 @@ class CodeRunner
|
|
114
114
|
2
|
115
115
|
end
|
116
116
|
def init_repository(name, copts)
|
117
|
-
|
118
|
-
repo.init_metadata
|
119
|
-
repo.init_readme
|
120
|
-
repo.init_defaults_folder
|
117
|
+
Repository.init(name)
|
121
118
|
end
|
122
119
|
def add_remote(name, url, copts)
|
120
|
+
url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
121
|
+
folder = $~[:folder]
|
122
|
+
if folder =~ /\.git$/
|
123
|
+
raise "Remotes cannot end in .git for coderunnerrepo"
|
124
|
+
end
|
123
125
|
Dir.chdir(copts[:Y]){
|
124
|
-
repo = Repository.
|
125
|
-
repo.add_remote(name, url)
|
126
|
+
repo = Repository.open_in_subfolder(Dir.pwd)
|
127
|
+
repo.bare_repo.add_remote(name, url)
|
126
128
|
}
|
127
129
|
end
|
128
130
|
def try_system(str)
|
131
|
+
puts str
|
129
132
|
raise "Failed command: #{str}" unless system str
|
130
133
|
end
|
131
134
|
def push_and_create_repository(copts)
|
132
135
|
Dir.chdir(copts[:Y]){
|
133
|
-
repo = Repository.
|
136
|
+
repo = Repository.open_in_subfolder(Dir.pwd)
|
137
|
+
bare_repo = repo.bare_repo
|
134
138
|
if copts[:r]
|
135
|
-
rems = copts[:r].split(/,/).map{|rname|
|
139
|
+
rems = copts[:r].split(/,/).map{|rname| bare_repo.remote(rname)}
|
136
140
|
else
|
137
141
|
raise "Must specify remotes using the -r flag when calling push_and_create_repository"
|
138
142
|
end
|
143
|
+
repo.simple_push(repo.remote("origin"))
|
139
144
|
rems.each do |r|
|
140
145
|
r.url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
|
141
146
|
namehost = $~[:namehost]
|
142
147
|
folder = $~[:folder]
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
+
barefolder = folder + '.git'
|
149
|
+
p namehost, barefolder
|
150
|
+
if folder =~ /\.git$/
|
151
|
+
raise "Remotes must not end in .git for coderunnerrepo"
|
152
|
+
end
|
153
|
+
#barefolder =folder.sub(/\/+$/, '') + '.git'
|
154
|
+
#try_system %[git bundle create .tmpbundle --all]
|
155
|
+
try_system %[ssh #{namehost} "mkdir -p #{barefolder} && cd #{barefolder} && git init --bare"]
|
156
|
+
bare_repo.push(r)
|
157
|
+
try_system %[ssh #{namehost} "git clone #{barefolder} #{folder}"]
|
158
|
+
#try_system %[scp .tmpbundle #{namehost}:#{folder}/../.]
|
159
|
+
#try_system %[rm .tmpbundle]
|
148
160
|
#try_system %[ssh #{namehost} "cd #{folder} && git clone .tmpbundle #{repname = File.basename(repo.dir.to_s)} "]
|
149
|
-
try_system %[ssh #{namehost} "cd #{folder} && git clone ../.tmpbundle ."]
|
161
|
+
#try_system %[ssh #{namehost} "cd #{folder} && git clone ../.tmpbundle ."]
|
150
162
|
#try_system %[ssh #{namehost} "cd #{folder}/#{repname} && git remote rm origin"]
|
151
|
-
try_system %[ssh #{namehost} "cd #{folder} && git remote rm origin"]
|
163
|
+
#try_system %[ssh #{namehost} "cd #{folder} && git remote rm origin"]
|
152
164
|
#push_repository(copts.dup.absorb(r: r.name))
|
153
|
-
|
165
|
+
bare_repo.remotes.each do |other_remote|
|
154
166
|
next if other_remote.name == r.name
|
155
167
|
try_system %[ssh #{namehost} "cd #{folder} && git remote add #{other_remote.name} #{other_remote.url}"]
|
156
168
|
#try_system %[ssh #{namehost} "cd #{folder} && git remote add #{other_remote.name} #{other_remote.url}"]
|
@@ -162,20 +174,20 @@ class CodeRunner
|
|
162
174
|
Dir.chdir(copts[:Y]){
|
163
175
|
repo = Repository.open(Dir.pwd)
|
164
176
|
if copts[:r]
|
165
|
-
rems = copts[:r].split(/,/).map{|rname| repo.remote(rname)}
|
177
|
+
rems = copts[:r].split(/,/).map{|rname| repo.bare_repo.remote(rname)}
|
166
178
|
else
|
167
|
-
rems = repo.remotes
|
179
|
+
rems = repo.bare_repo.remotes
|
168
180
|
end
|
169
181
|
rems.each{|r| repo.push(r)}
|
170
182
|
}
|
171
183
|
end
|
172
184
|
def pull_repository(copts)
|
173
185
|
Dir.chdir(copts[:Y]){
|
174
|
-
repo = Repository.
|
186
|
+
repo = Repository.open_in_subfolder(Dir.pwd)
|
175
187
|
if copts[:r]
|
176
|
-
rems = copts[:r].split(/,/).map{|rname| repo.remote(rname)}
|
188
|
+
rems = copts[:r].split(/,/).map{|rname| repo.bare_repo.remote(rname)}
|
177
189
|
else
|
178
|
-
rems = repo.remotes
|
190
|
+
rems = repo.bare_repo.remotes
|
179
191
|
end
|
180
192
|
rems.each{|r| repo.pull(r)}
|
181
193
|
}
|
data/test/test_coderunnerrepo.rb
CHANGED
@@ -32,17 +32,19 @@ class TestCreate < MiniTest::Test
|
|
32
32
|
FileUtils.makedirs(tfolder)
|
33
33
|
string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
|
34
34
|
Dir.chdir('test'){CodeRunner.generate_cubecalc}
|
35
|
-
Dir.chdir(tfolder){assert_system string}
|
35
|
+
Dir.chdir(tfolder){assert_system string; FileUtils.rm('../cubecalc.cc')}
|
36
36
|
end
|
37
37
|
def test_create
|
38
38
|
Dir.chdir(tfolder) {
|
39
39
|
assert_system("#$coderunnerrepo_command init myrepo")
|
40
|
-
assert_system("#$coderunnerrepo_command adrm local ssh://#{ENV['USER']}
|
40
|
+
assert_system("#$coderunnerrepo_command adrm local ssh://#{ENV['USER']}@localhost/#{Dir.pwd}/remote -Y myrepo")
|
41
|
+
#assert_system("#$coderunnerrepo_command adrm local ssh://#{ENV['USER']}@#{`hostname`.chomp}.local/#{Dir.pwd}/remote.git -Y myrepo")
|
41
42
|
assert_system("#$coderunnerrepo_command adrm dummy ssh://dummyuser@nohost/#{Dir.pwd}/remote -Y myrepo")
|
42
43
|
assert_system("#$coderunnerrepo_command pushcr -r local -Y myrepo")
|
43
44
|
#assert_equal(false, system("#$coderunnerrepo_command pushcr -r local -Y myrepo"))
|
44
|
-
assert_system("cd myrepo; git remote rm dummy")
|
45
|
+
assert_system("cd myrepo.git; git remote rm dummy")
|
45
46
|
assert_system("#$coderunnerrepo_command pull -Y myrepo")
|
47
|
+
assert_system("#$coderunnerrepo_command push -Y myrepo")
|
46
48
|
FileUtils.makedirs(dffolder)
|
47
49
|
FileUtils.touch(dffolder + '/code_runner_info.rb')
|
48
50
|
FileUtils.touch(dffolder + '/code_runner_results.rb')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edmund Highcock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphkit
|