@@ -11,15 +11,19 @@ def get_file_paths(dir, recursive = true)
11
11
get_tree ( get_tree_sha ( dir ) , recursive ) [ 'tree' ] . select { |f | f [ 'type' ] == 'blob' } . map { |f | f [ 'path' ] }
12
12
end
13
13
14
+ def file_url ( path )
15
+ "https://raw.githubusercontent.com/#@repo /#@branch_sha /#{ path } "
16
+ end
17
+
14
18
def read_files ( path , files )
15
- full_path = "https://raw.githubusercontent.com/#%3C/span%3E%3Cspan%20class="pl-c1 x">@repo /# @branch_sha / #{ path } "
19
+ path_url = file_url path
16
20
contents = read_cached_files ( path , files )
17
- log_http_get_files contents . keys , full_path , true if contents . keys
21
+ log_http_get_files contents . keys , path_url , true if contents . keys
18
22
files -= contents . keys
19
- log_http_get_files files , full_path , false
23
+ log_http_get_files files , path_url , false
20
24
files . map do |name |
21
25
Thread . start {
22
- contents [ name ] = open ( "#{ full_path } /#{ name } " ) . read
26
+ contents [ name ] = open ( "#{ path_url } /#{ name } " ) . read
23
27
Thread . exclusive { write_cached_files path , name => contents [ name ] }
24
28
}
25
29
end . each ( &:join )
@@ -65,7 +69,7 @@ def get_file(url)
65
69
# get sha of the branch (= the latest commit)
66
70
def get_branch_sha
67
71
@branch_sha ||= begin
68
- if @branch + " \n " == %x[git rev-parse -- # @branch ]
72
+ if @branch =~ / \A [0-9a-f]{40,} \z /
69
73
@branch
70
74
else
71
75
cmd = "git ls-remote #{ Shellwords . escape "https://github.com/#@repo " } #@branch "
0 commit comments