@@ -23,7 +23,20 @@ impl GraphQLHelper {
23
23
. join ( path) ;
24
24
let path = normalize_path ( & path) ;
25
25
26
- let transaction = cache:: Transaction :: open ( & self . repo_path , Some ( & self . ref_prefix ) ) ?;
26
+ let transaction = if let Ok ( to) =
27
+ cache:: Transaction :: open ( & self . repo_path . join ( "mirror" ) , Some ( & self . ref_prefix ) )
28
+ {
29
+ to. repo ( ) . odb ( ) ?. add_disk_alternate (
30
+ self . repo_path
31
+ . join ( "overlay" )
32
+ . join ( "objects" )
33
+ . to_str ( )
34
+ . unwrap ( ) ,
35
+ ) ?;
36
+ to
37
+ } else {
38
+ cache:: Transaction :: open ( & self . repo_path , Some ( & self . ref_prefix ) ) ?
39
+ } ;
27
40
28
41
let tree = transaction. repo ( ) . find_commit ( self . commit_id ) ?. tree ( ) ?;
29
42
@@ -41,8 +54,26 @@ impl GraphQLHelper {
41
54
variables. insert ( k. to_string ( ) , juniper:: InputValue :: scalar ( v. render ( ) ) ) ;
42
55
}
43
56
44
- let transaction = cache:: Transaction :: open ( & self . repo_path , None ) ?;
45
- let transaction_overlay = cache:: Transaction :: open ( & self . repo_path , None ) ?;
57
+ let ( transaction, transaction_overlay) =
58
+ if let Ok ( to) = cache:: Transaction :: open ( & self . repo_path . join ( "overlay" ) , None ) {
59
+ to. repo ( ) . odb ( ) ?. add_disk_alternate (
60
+ self . repo_path
61
+ . join ( "mirror" )
62
+ . join ( "objects" )
63
+ . to_str ( )
64
+ . unwrap ( ) ,
65
+ ) ?;
66
+ (
67
+ cache:: Transaction :: open ( & self . repo_path . join ( "mirror" ) , None ) ?,
68
+ to,
69
+ )
70
+ } else {
71
+ (
72
+ cache:: Transaction :: open ( & self . repo_path , None ) ?,
73
+ cache:: Transaction :: open ( & self . repo_path , None ) ?,
74
+ )
75
+ } ;
76
+
46
77
let ( res, _errors) = juniper:: execute_sync (
47
78
& query,
48
79
None ,
@@ -77,7 +108,7 @@ impl handlebars::HelperDef for GraphQLHelper {
77
108
h. hash ( ) ,
78
109
rc. get_current_template_name ( ) . unwrap_or ( & "/" . to_owned ( ) ) ,
79
110
)
80
- . map_err ( |_ | handlebars:: RenderError :: new ( "josh" ) ) ?,
111
+ . map_err ( |e | handlebars:: RenderError :: new ( format ! ( "{}" , e ) ) ) ?,
81
112
) ) ;
82
113
}
83
114
}
@@ -162,13 +193,25 @@ pub fn render(
162
193
drop ( obj) ;
163
194
drop ( tree) ;
164
195
196
+ let repo_path =
197
+ if transaction. repo ( ) . path ( ) . file_name ( ) == Some ( std:: ffi:: OsStr :: new ( "overlay" ) ) {
198
+ transaction
199
+ . repo ( )
200
+ . path ( )
201
+ . parent ( )
202
+ . ok_or ( josh_error ( "parent" ) ) ?
203
+ . to_owned ( )
204
+ } else {
205
+ transaction. repo ( ) . path ( ) . to_owned ( )
206
+ } ;
207
+
165
208
let mut handlebars = handlebars:: Handlebars :: new ( ) ;
166
209
handlebars. register_template_string ( path, template) ?;
167
210
handlebars. register_helper ( "concat" , Box :: new ( helpers:: concat_helper) ) ;
168
211
handlebars. register_helper (
169
212
"graphql" ,
170
213
Box :: new ( GraphQLHelper {
171
- repo_path : transaction . repo ( ) . path ( ) . to_owned ( ) ,
214
+ repo_path : repo_path ,
172
215
ref_prefix : ref_prefix. to_owned ( ) ,
173
216
commit_id,
174
217
} ) ,
0 commit comments