cpack_repository/commit

Only resolve files using GIT if we are xreffing a git repo

authorJan Wielemaker
Tue Nov 23 12:00:34 2010 +0100
committerJan Wielemaker
Tue Nov 23 12:00:34 2010 +0100
commit821f3237ff7e25bcc512fc8be5cb22bfed53370e
tree6a27d0bff1c5ea698d263ffc6b01873971ff8e55
parent35fb4cf9e780ab5cd2128c49197b1e37df89581b
Diff style: patch stat
diff --git a/applications/cpack_submit.pl b/applications/cpack_submit.pl
index 4a19bfc..8205f41 100644
--- a/applications/cpack_submit.pl
+++ b/applications/cpack_submit.pl
@@ -46,6 +46,7 @@
 http:location(cpack_api,  api(cpack),  []).
 
 :- http_handler(cpack(submit),		   cpack_submit_form,	     []).
+:- http_handler(cpack(clone_server),	   cpack_clone_server_form,  []).
 :- http_handler(cpack(list_packages),	   cpack_list_packages,	     []).
 :- http_handler(cpack(my_packages),	   cpack_my_packages,	     []).
 :- http_handler(cpack(update_my_packages), cpack_update_my_packages, []).
@@ -241,4 +242,9 @@ git_show(Request) :-
 			]).
 
 
+%%	cpack_clone_server_form(+Request)
+%
+%	Provide a form to clone a CPACK server
 
+cpack_clone_server_form(_Request) :-
+	true.
diff --git a/config-available/cpack_repository.pl b/config-available/cpack_repository.pl
index a9aeb7d..126af27 100644
--- a/config-available/cpack_repository.pl
+++ b/config-available/cpack_repository.pl
@@ -18,6 +18,7 @@ cliopatria:menu_label(cpack, 'CPACK').
 
 cliopatria:menu_item(100=cpack/cpack_list_packages, 'List packs').
 cliopatria:menu_item(200=cpack/cpack_submit_form,   'Submit pack').
+cliopatria:menu_item(300=cpack/clone_server_form,   'Clone server').
 cliopatria:menu_item(275=current_user/cpack_my_packages, 'My CPACKs') :-
 	logged_on(_).
 
diff --git a/lib/cpack/xref.pl b/lib/cpack/xref.pl
index 004f562..3c2193d 100644
--- a/lib/cpack/xref.pl
+++ b/lib/cpack/xref.pl
@@ -73,10 +73,16 @@ pack_prolog_file(Pack, File) :-
 %	  * cpack:module
 %	  * cpack:exportsPredicate
 
+:- thread_local
+	xref_git/0.
+
 xref_cpack_file(File) :-
 	print_message(informational, cpack(xref(File))),
-	xref_source(File),
-	xref_to_rdf(File).
+	setup_call_cleanup(assert(xref_git, Ref),
+			   (   xref_source(File),
+			       xref_to_rdf(File)
+			   ),
+			   erase(Ref)).
 
 :- rdf_meta
 	file_property(r,r,o).
@@ -351,6 +357,7 @@ prolog:xref_source_identifier(File, File) :-
 %	the cross-referencer to analyse files in GIT repositories.
 
 prolog:xref_source_file(Spec, File, _Options) :-
+	xref_git,
 	rdf_is_resource(Spec),
 	(   File = Spec
 	;   prolog_file_type(Ext, prolog),
@@ -358,6 +365,7 @@ prolog:xref_source_file(Spec, File, _Options) :-
 	),
 	rdfs_individual_of(File, cpack:'File'), !.
 prolog:xref_source_file(Spec, File, _Options) :-
+	xref_git,
 	search_file(Spec, File), !.