dev 1.0.143 → 1.0.144
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dev/Database.rb +55 -0
- data/lib/dev/Project.rb +63 -28
- data/lib/dev.rb +1 -1
- metadata +2 -1
data/lib/dev/Database.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'sqlite3'
|
2
|
+
|
3
|
+
module Dev
|
4
|
+
#
|
5
|
+
# Branches table
|
6
|
+
# Name text e.g. google/devgem/trunk
|
7
|
+
# Uri text e.g. https://devgem.googlecode.com/svn/trunk
|
8
|
+
#
|
9
|
+
# create table Branches(Name text,Uri text,UNIQUE(Name));
|
10
|
+
#
|
11
|
+
class Database
|
12
|
+
attr_accessor :db
|
13
|
+
|
14
|
+
def self.filename
|
15
|
+
return Dev::Environment.dev_root + "/dev.db"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get_table_names(filename)
|
19
|
+
names=Array.new
|
20
|
+
db = SQLite3::Database.new filename
|
21
|
+
db.execute("select name from sqlite_master where type='table' ORDER BY name") do |row|
|
22
|
+
names << row[0]
|
23
|
+
end
|
24
|
+
return names
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
filename=Dev::Database.filename
|
29
|
+
table_names=Dev::Database.get_table_names(filename)
|
30
|
+
@db = SQLite3::Database.new filename
|
31
|
+
@db.execute("create table Branches(Name text,Uri text,UNIQUE(Name));") if !table_names.include? "Branches"
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_branch_uri(name,uri)
|
35
|
+
@db.execute("insert or replace into Branches (Name,Uri) VALUES ('#{name}','#{uri}');")
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_branch_uri(name,uri)
|
39
|
+
@db.execute("select Uri from Branches where Name='#{name}';") do |row|
|
40
|
+
return row[0]
|
41
|
+
end
|
42
|
+
return ""
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_branches(pattern)
|
46
|
+
names=Array.new
|
47
|
+
sql="select Name from Branches where Name LIKE '#{pattern}';"
|
48
|
+
sql="select Name from Branches;" if pattern.nil? || pattern.length==0
|
49
|
+
@db.execute(sql) do |row|
|
50
|
+
names << row[0]
|
51
|
+
end
|
52
|
+
return names
|
53
|
+
end
|
54
|
+
end # class Database
|
55
|
+
end # module Dev
|
data/lib/dev/Project.rb
CHANGED
@@ -17,20 +17,28 @@ class Project < Hash
|
|
17
17
|
|
18
18
|
def defaults
|
19
19
|
system_call = Dev::SystemCall.new("semver init") if(!File.exist?(".semver"))
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}
|
20
|
+
h=Hash.new
|
21
|
+
h[:scm_uri] = get_default_scm_uri if !get_default_scm_uri.nil?
|
22
|
+
h[:scm_type] = get_default_scm_type if !get_default_scm_type.nil?
|
23
|
+
h[:directory]=Rake.original_dir()
|
24
|
+
h[:fullname]=get_default_value_fullname
|
25
|
+
h[:group]=get_default_value_group
|
26
|
+
h[:name]=get_default_value_name
|
27
|
+
h[:version]= "#{SemVer.find.major}.#{SemVer.find.minor}.#{SemVer.find.patch}"
|
28
|
+
h[:src_glob]="**/{*.{rb,feature,spec,cs,c,cpp,h,hpp,csproj,vcproj,snk,vcxproj,sln,filters,xaml,xml,resx,settings,txt,png,bmp,ico},Jamfile,.semver,Gemfile,README,LICENSE}"
|
29
|
+
h[:type]=get_default_value_type
|
30
|
+
h[:dev_root]= "#{Dev::Environment.dev_root}"
|
29
31
|
if !Dev::BoostBuild.defaultToolset.nil?
|
30
32
|
h[:toolset] = Dev::BoostBuild.defaultToolset
|
31
33
|
ENV["VisualStudioVersion"]="11.0" if h[:toolset]=="msvc-11.0"
|
32
34
|
end
|
33
|
-
|
35
|
+
|
36
|
+
h[:file_count]=Hash.new
|
37
|
+
["rb","spec","feature","cs","cpp","h","hpp","vcxproj","csproj"].each{ |ext|
|
38
|
+
count=Dir.glob("**/*.#{ext}").count
|
39
|
+
h[:file_count][ext.to_sym]=count if count > 0
|
40
|
+
}
|
41
|
+
|
34
42
|
tmp=get_default_value_paths
|
35
43
|
h[:paths] = tmp if !tmp.nil?
|
36
44
|
return h
|
@@ -38,6 +46,8 @@ class Project < Hash
|
|
38
46
|
|
39
47
|
def refresh
|
40
48
|
update_default_values
|
49
|
+
db = Dev::Database.new
|
50
|
+
db.set_branch_uri(self[:fullname],self[:scm_uri])
|
41
51
|
end
|
42
52
|
def update_default_values
|
43
53
|
puts_debug "update_default_values"
|
@@ -66,6 +76,15 @@ class Project < Hash
|
|
66
76
|
return nil
|
67
77
|
end
|
68
78
|
|
79
|
+
def get_default_value_fullname
|
80
|
+
wrk="#{Dev::Environment.dev_root}/wrk/"
|
81
|
+
if(Rake.original_dir.include?(wrk))
|
82
|
+
name=Rake.original_dir.gsub(wrk,"")
|
83
|
+
return name if(name.split('/').count==3)
|
84
|
+
end
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
69
88
|
def get_default_value_group
|
70
89
|
dirs=Rake.original_dir().split('/')
|
71
90
|
return dirs[dirs.length-3] if(dirs.length > 3)
|
@@ -86,6 +105,17 @@ class Project < Hash
|
|
86
105
|
return nil
|
87
106
|
end
|
88
107
|
|
108
|
+
def get_default_scm_uri
|
109
|
+
|
110
|
+
if File.exists?(".svn")
|
111
|
+
text=`svn info`
|
112
|
+
text.scan(/URL: ([\w:\/.-]+)/).each { |m|
|
113
|
+
return m
|
114
|
+
}
|
115
|
+
end
|
116
|
+
return nil
|
117
|
+
end
|
118
|
+
|
89
119
|
def get_default_value_paths
|
90
120
|
hash=Hash.new
|
91
121
|
|
@@ -96,10 +126,15 @@ class Project < Hash
|
|
96
126
|
hash[:regasm]=f if File.exists?(f) && hash[:regasm].nil?
|
97
127
|
}
|
98
128
|
|
99
|
-
["2.
|
129
|
+
["2.6.0.12051","2.5.10.11092"].each{ |v|
|
100
130
|
Dir.glob("#{Dev::Environment.dev_root}/dep/*/NUnit/#{v}/bin/nunit-console-x86.exe").each{|f|
|
101
131
|
hash[:nunit]=f if File.exists?(f) && hash[:nunit].nil?
|
102
132
|
}
|
133
|
+
if( !hash.has_key?(:nunit) )
|
134
|
+
Dir.glob("#{Dev::Environment.dev_root}/dep/*/NUnit/#{v}/bin/*/nunit-console-x86.exe").each{|f|
|
135
|
+
hash[:nunit]=f if File.exists?(f) && hash[:nunit].nil?
|
136
|
+
}
|
137
|
+
end
|
103
138
|
}
|
104
139
|
|
105
140
|
hash=nil if hash.length < 1
|
@@ -257,23 +292,22 @@ class Project < Hash
|
|
257
292
|
end
|
258
293
|
|
259
294
|
def generate_auto_replace_directives
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
if
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
self[:replace][k]={ glob: '**/*.csproj', search: searchRegex, replace: "#{group}\\#{k}\\#{v[:rev]}" }
|
295
|
+
# only generate replace directives if a commit may be made...
|
296
|
+
if(self[:scm_type]=="svn" || self[:scm_type]=="git")
|
297
|
+
["vcxproj","csproj"].each { |ext|
|
298
|
+
if(self[:file_count].has_key?(ext.to_sym) && self[:file_count][ext.to_sym] > 0)
|
299
|
+
self[:replace]=Hash.new if self[:replace].nil?
|
300
|
+
self[:dep].each{ |k,v|
|
301
|
+
if !self[:dep][k].has_key?(:rev) && self[:dep][k].has_key?(:uri)
|
302
|
+
words=self[:dep][k][:uri].split('@')
|
303
|
+
self[:dep][k][:rev]=words[1] if words.count==2
|
304
|
+
end
|
305
|
+
if self[:dep][k].has_key?(:rev) && self[:dep][k].has_key?(:dir) && !self[:replace].has_key?(k)
|
306
|
+
group=self[:dep][k][:dir].split('/')[0]
|
307
|
+
searchRegex=Regexp.new "#{group}\\\\#{k}\\\\[\\d]+"
|
308
|
+
self[:replace][k]={ glob: '**/*.#{ext}', search: searchRegex, replace: "#{group}\\#{k}\\#{v[:rev]}" }
|
309
|
+
end
|
310
|
+
}
|
277
311
|
end
|
278
312
|
}
|
279
313
|
end
|
@@ -555,3 +589,4 @@ end # module Dev
|
|
555
589
|
|
556
590
|
PROJECT=Dev::Project.new(nil,true)
|
557
591
|
PROJECT.refresh
|
592
|
+
DEV=PROJECT
|
data/lib/dev.rb
CHANGED
@@ -42,7 +42,7 @@ puts_debug "read " + __FILE__.foreground(:green)
|
|
42
42
|
#require "#{File.dirname(__FILE__)}/dev/Environment.rb"
|
43
43
|
#require "#{File.dirname(__FILE__)}/dev/Hash.rb"
|
44
44
|
#require "#{File.dirname(__FILE__)}/dev/SystemCall.rb"
|
45
|
-
["Tasks","Environment","Hash","SystemCall"].each{ |f| require "#{File.dirname(__FILE__)}/dev/#{f}.rb" }
|
45
|
+
["Tasks","Environment","Hash","SystemCall","Database"].each{ |f| require "#{File.dirname(__FILE__)}/dev/#{f}.rb" }
|
46
46
|
Dir["#{File.dirname(__FILE__)}/dev/**/*.rb"].each{ |f| require f }
|
47
47
|
|
48
48
|
DEV_ROOT=Dev::Environment.dev_root
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.144
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- LICENSE
|
166
166
|
- README
|
167
167
|
- lib/dev/BoostBuild.rb
|
168
|
+
- lib/dev/Database.rb
|
168
169
|
- lib/dev/Dep.rb
|
169
170
|
- lib/dev/Environment.rb
|
170
171
|
- lib/dev/Hash.rb
|