cpee-model-management 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cpee-model-management.gemspec +1 -1
- data/lib/cpee-model-management/commit.rb +14 -0
- data/lib/cpee-model-management/implementation.rb +119 -56
- data/server/moma +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2301d22c5a02dcace2fa736c3b41b88d02866c2cb2f3b68b2554e0766224486e
|
4
|
+
data.tar.gz: d8f20b6c8c5c620dab0f582566a3445f6b48498cecd36ea7670096d80319166c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8de486ecdffc9c0cf93a7ca043e0d1363210d679223528270f9aa02e97aa2106386bb9a0240237f0c115321ea58127e13d0c24e33e414695ee1896676e88fa7
|
7
|
+
data.tar.gz: 711f92a0d044bd8bfc77cb56cd899df56343fd9fe80f9bc92170f4d86b0c5cced06edfd95f273879dbc59f59a27deaa7be4a25b5e572668621c062df7b9d82bd
|
@@ -0,0 +1,14 @@
|
|
1
|
+
models = ARGV[0]
|
2
|
+
new = ARGV[1]
|
3
|
+
author = ARGV[2]
|
4
|
+
|
5
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
6
|
+
new = File.basename(new)
|
7
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}" 2>/dev/null`
|
8
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.active" 2>/dev/null`
|
9
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.active-uuid" 2>/dev/null`
|
10
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.author" 2>/dev/null`
|
11
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.creator" 2>/dev/null`
|
12
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.stage" 2>/dev/null`
|
13
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple commit -m "#{author.gsub(/"/,"'")}"`
|
14
|
+
`GIT_TERMINAL_PROMPT=0 git push` rescue nil
|
@@ -22,72 +22,135 @@ require 'riddl/server'
|
|
22
22
|
require 'riddl/client'
|
23
23
|
require 'riddl/protocols/utils'
|
24
24
|
require 'fileutils'
|
25
|
+
require 'pathname'
|
26
|
+
require 'shellwords'
|
25
27
|
|
26
28
|
module CPEE
|
27
29
|
module ModelManagement
|
28
30
|
|
29
31
|
SERVER = File.expand_path(File.join(__dir__,'moma.xml'))
|
30
32
|
|
33
|
+
def self::git_mv(models,old,new)
|
34
|
+
cdir = Dir.pwd
|
35
|
+
Dir.chdir(File.join(models,File.dirname(old)))
|
36
|
+
p1 = Pathname.new(File.dirname(old))
|
37
|
+
p2 = Pathname.new(File.dirname(new))
|
38
|
+
old = File.basename(old)
|
39
|
+
new = File.join(p1.relative_path_from(p1).to_s,File.basename(new))
|
40
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old}" "#{new}" 2>/dev/null`
|
41
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{old + '.active'}" 2>/dev/null`
|
42
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{old + '.active-uuid'}" 2>/dev/null`
|
43
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.author'}" "#{new + '.author'}" 2>/dev/null`
|
44
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.creator'}" "#{new + '.creator'}" 2>/dev/null`
|
45
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.stage'}" "#{new + '.stage'}" 2>/dev/null`
|
46
|
+
Dir.chdir(cdir)
|
47
|
+
end
|
48
|
+
def self::git_rm(models,new)
|
49
|
+
cdir = Dir.pwd
|
50
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
51
|
+
new = File.basename(new)
|
52
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}" 2>/dev/null`
|
53
|
+
FileUtils.rm_rf(new)
|
54
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active" 2>/dev/null`
|
55
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active-uuid" 2>/dev/null`
|
56
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.author" 2>/dev/null`
|
57
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.creator" 2>/dev/null`
|
58
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.stage" 2>/dev/null`
|
59
|
+
Dir.chdir(cdir)
|
60
|
+
end
|
61
|
+
def self::git_shift(models,new)
|
62
|
+
cdir = Dir.pwd
|
63
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
64
|
+
new = File.basename(new)
|
65
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active" 2>/dev/null`
|
66
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active-uuid" 2>/dev/null`
|
67
|
+
Dir.chdir(cdir)
|
68
|
+
end
|
69
|
+
def self::git_commit(models,new,author)
|
70
|
+
rp = File.realpath(models)
|
71
|
+
crb = File.join(__dir__,'commit.rb')
|
72
|
+
system 'ruby ' + crb + ' ' + [rp, new, author].shelljoin + ' &'
|
73
|
+
end
|
74
|
+
def self::fs_mv(models,old,new)
|
75
|
+
fname = File.join(models,old)
|
76
|
+
fnname = File.join(models,new)
|
77
|
+
FileUtils.mv(fname,fnname)
|
78
|
+
File.delete(fname + '.active',fnname + '.active') rescue nil
|
79
|
+
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
80
|
+
FileUtils.mv(fname + '.author',fnname + '.author') rescue nil
|
81
|
+
FileUtils.mv(fname + '.creator',fnname + '.creator') rescue nil
|
82
|
+
FileUtils.mv(fname + '.stage',fnname + '.stage') rescue nil
|
83
|
+
end
|
84
|
+
def self::fs_cp(models,old,new)
|
85
|
+
fname = File.join(models,old)
|
86
|
+
fnname = File.join(models,new)
|
87
|
+
FileUtils.cp(fname,fnname)
|
88
|
+
File.delete(fname + '.active',fnname + '.active') rescue nil
|
89
|
+
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
90
|
+
FileUtils.cp(fname + '.author',fnname + '.author') rescue nil
|
91
|
+
FileUtils.cp(fname + '.creator',fnname + '.creator') rescue nil
|
92
|
+
FileUtils.cp(fname + '.stage',fnname + '.stage') rescue nil
|
93
|
+
end
|
94
|
+
def self::fs_rm(models,new)
|
95
|
+
fname = File.join(models,new)
|
96
|
+
FileUtils.rm_rf(fname)
|
97
|
+
File.delete(fname + '.active') rescue nil
|
98
|
+
File.delete(fname + '.active-uuid') rescue nil
|
99
|
+
File.delete(fname + '.author') rescue nil
|
100
|
+
File.delete(fname + '.creator') rescue nil
|
101
|
+
File.delete(fname + '.stage') rescue nil
|
102
|
+
end
|
103
|
+
def self::fs_shift(models,new)
|
104
|
+
fname = File.join(models,new)
|
105
|
+
File.delete(fname + '.active') rescue nil
|
106
|
+
File.delete(fname + '.active-uuid') rescue nil
|
107
|
+
Dir.chdir(cdir)
|
108
|
+
end
|
109
|
+
|
110
|
+
def self::git_dir(models,file)
|
111
|
+
return nil if file.nil?
|
112
|
+
cdir = Dir.pwd
|
113
|
+
tdir = File.dirname(file)
|
114
|
+
Dir.chdir(File.join(models,tdir))
|
115
|
+
res = `git rev-parse --absolute-git-dir 2>/dev/null`
|
116
|
+
Dir.chdir(cdir)
|
117
|
+
res == '' ? nil : res
|
118
|
+
end
|
119
|
+
|
31
120
|
def self::op(author,op,models,new,old=nil) #{{{
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
`git rm -rf "#{fname}.active-uuid" 2>/dev/null`
|
121
|
+
git_ndir = CPEE::ModelManagement::git_dir(models,new)
|
122
|
+
git_odir = CPEE::ModelManagement::git_dir(models,old)
|
123
|
+
|
124
|
+
if op == 'rm' && !git_ndir.nil?
|
125
|
+
git_rm models, new
|
126
|
+
git_commit models, new, author
|
127
|
+
elsif op == 'shift' && !git_ndir.nil?
|
128
|
+
git_shift models, new
|
129
|
+
git_commit models, new, author
|
130
|
+
elsif op == 'mv' && (!git_ndir.nil? || !git_odir.nil?)
|
131
|
+
if git_ndir == git_odir
|
132
|
+
git_mv models, old, new
|
133
|
+
git_commit models, new, author
|
134
|
+
elsif git_ndir != git_odir && !git_ndir.nil? && !git_odir.nil?
|
135
|
+
fs_cp models, old, new
|
136
|
+
git_rm models, old
|
137
|
+
git_commit models, old, author
|
138
|
+
git_commit models, new, author
|
139
|
+
elsif git_ndir != git_odir && git_ndir.nil?
|
140
|
+
fs_cp models, old, new
|
141
|
+
git_rm models, old
|
142
|
+
git_commit models, old, author
|
143
|
+
elsif git_ndir != git_odir && git_odir.nil?
|
144
|
+
fs_mv models, old, new
|
145
|
+
git_commit models, new, author
|
58
146
|
end
|
59
|
-
|
60
|
-
|
61
|
-
`git add "#{fname}.active" 2>/dev/null`
|
62
|
-
`git add "#{fname}.active-uuid" 2>/dev/null`
|
63
|
-
`git add "#{fname}.author" 2>/dev/null`
|
64
|
-
`git add "#{fname}.creator" 2>/dev/null`
|
65
|
-
`git add "#{fname}.stage" 2>/dev/null`
|
66
|
-
`git commit -m "#{author.gsub(/"/,"'")}"`
|
67
|
-
Dir.chdir(cdir)
|
147
|
+
elsif !git_ndir.nil?
|
148
|
+
git_commit models, new, author
|
68
149
|
else
|
69
150
|
case op
|
70
|
-
when 'mv'
|
71
|
-
|
72
|
-
|
73
|
-
FileUtils.mv(fname,fnname)
|
74
|
-
File.delete(fname + '.active',fnname + '.active') rescue nil
|
75
|
-
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
76
|
-
FileUtils.mv(fname + '.author',fnname + '.author') rescue nil
|
77
|
-
FileUtils.mv(fname + '.creator',fnname + '.creator') rescue nil
|
78
|
-
FileUtils.mv(fname + '.stage',fnname + '.stage') rescue nil
|
79
|
-
when 'rm'
|
80
|
-
fname = File.join(models,new)
|
81
|
-
FileUtils.rm_rf(fname)
|
82
|
-
File.delete(fname + '.active') rescue nil
|
83
|
-
File.delete(fname + '.active-uuid') rescue nil
|
84
|
-
File.delete(fname + '.author') rescue nil
|
85
|
-
File.delete(fname + '.creator') rescue nil
|
86
|
-
File.delete(fname + '.stage') rescue nil
|
87
|
-
when 'shift'
|
88
|
-
fname = File.join(models,new)
|
89
|
-
File.delete(fname + '.active') rescue nil
|
90
|
-
File.delete(fname + '.active-uuid') rescue nil
|
151
|
+
when 'mv'; fs_mv(models,old,new)
|
152
|
+
when 'rm'; fs_rm(models,new)
|
153
|
+
when 'shift'; fs_shift(models,new)
|
91
154
|
end
|
92
155
|
end
|
93
156
|
end #}}}
|
data/server/moma
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-model-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: tools
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riddl
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- cpee-model-management.gemspec
|
54
|
+
- lib/cpee-model-management/commit.rb
|
54
55
|
- lib/cpee-model-management/implementation.rb
|
55
56
|
- lib/cpee-model-management/moma.xml
|
56
57
|
- lib/cpee-model-management/stages
|