5
5
6
6
vcs , repo_path , *rest = ARGV
7
7
case vcs
8
- when "svn"
9
- class SvnInfo
10
- def initialize ( repo_path , rev )
11
- @repo_path = repo_path
12
- @revision = Integer ( rev )
13
- get_changed
14
- end
15
-
16
- def branches
17
- [ *@added_files , *@updated_files ] . map { |x | x [ /((?:branches\/ )?.+?)\/ / , 1 ] } . uniq
18
- end
19
-
20
- private
21
-
22
- def get_changed
23
- @added_files = [ ]
24
- @updated_files = [ ]
25
- svnlook ( "changed" ) . each_line do |line |
26
- if /^(.). (.*)$/ =~ line
27
- modified_type = $1
28
- path = $2
29
- case modified_type
30
- when "A"
31
- add_path ( path , @added_files )
32
- when "D"
33
- # noop
34
- else
35
- add_path ( path , @updated_files )
36
- end
37
- else
38
- raise "unknown format: #{ line } "
39
- end
40
- end
41
- end
42
-
43
- def add_path ( path , files )
44
- unless directory_path? ( path )
45
- files << path
46
- end
47
- end
48
-
49
- def svnlook ( command , *others )
50
- `svnlook #{ command } #{ @repo_path } -r #{ @revision } #{ others . join ( ' ' ) } ` . force_encoding ( "ASCII-8BIT" )
51
- end
52
-
53
- def directory_path? ( path )
54
- path [ -1 ] == ?/
55
- end
56
- end
57
- branches = SvnInfo . new ( repo_path , rest . first ) . branches
58
8
when "git"
59
9
branches = rest . each_slice ( 3 ) . map do |_oldrev , _newrev , refname |
60
10
IO . popen ( [ "git" , "rev-parse" , "--symbolic" , "--abbrev-ref" , refname ] , &:read ) . strip
@@ -69,11 +19,7 @@ def directory_path?(path)
69
19
version_h = "#{ v } /version.h"
70
20
version_h_orig = version_h + "~"
71
21
72
- if vcs == "svn"
73
- system "pwd;echo 1;svn co --depth empty file:///#{ repo_path } /#{ branch } #{ v } ; svn up #{ version_h } "
74
- else # git
75
- system "git clone --depth=1 --branch=#{ branch } file:///#{ repo_path } #{ v } "
76
- end
22
+ system "git clone --depth=1 --branch=#{ branch } file:///#{ repo_path } #{ v } "
77
23
formats = {
78
24
'DATE' => [ /"\d {4}-\d \d -\d \d "/ , '"%Y-%m-%d"' ] ,
79
25
'TIME' => [ /".+"/ , '"%H:%M:%S"' ] ,
@@ -104,13 +50,9 @@ def directory_path?(path)
104
50
end
105
51
end
106
52
end
107
- if vcs == "svn"
108
- system "svn commit -m '#{ now . strftime %(* %Y-%m-%d) } ' #{ version_h } "
109
- else
110
- Dir . chdir ( v ) do
111
- unless system ( "git diff --quiet --exit-code #{ version_h } " )
112
- system "git add #{ version_h } && git commit -m '#{ now . strftime %(* %Y-%m-%d) } [ci skip]' && git push origin #{ branch } "
113
- end
53
+ Dir . chdir ( v ) do
54
+ unless system ( "git diff --quiet --exit-code #{ version_h } " )
55
+ system "git add #{ version_h } && git commit -m '#{ now . strftime %(* %Y-%m-%d) } [ci skip]' && git push origin #{ branch } "
114
56
end
115
57
end
116
58
end
0 commit comments