[HACK] gitweb: Support hiding of chosen repositories from project list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes it possible to hide certain repository from project list
(while still keeping it accessible, so it's not just an inverse of
 export-ok). By default the file that needs to be created in the
repository is '.hide'.

Signed-off-by: Petr Baudis <pasky@xxxxxxx>
---

  I used this for something at repo.or.cz, but it is actually lying around
unused in my patch queue now; before removing it, I'm going to archive it on
the mailing list, maybe someone will find it useful.

 Makefile           |    2 ++
 gitweb/gitweb.perl |   11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Makefile b/Makefile
index 3314dd6..b7c7f42 100644
--- a/Makefile
+++ b/Makefile
@@ -195,6 +195,7 @@ GITWEB_SITENAME =
 GITWEB_PROJECTROOT = /pub/git
 GITWEB_PROJECT_MAXDEPTH = 2007
 GITWEB_EXPORT_OK =
+GITWEB_HIDE_REPO = .hide
 GITWEB_STRICT_EXPORT =
 GITWEB_BASE_URL =
 GITWEB_LIST =
@@ -1130,6 +1131,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 	    -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 	    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
+	    -e 's|++GITWEB_HIDE_REPO++|$(GITWEB_HIDE_REPO)|g' \
 	    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 	    -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 	    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3b02d87..7ad0faa 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -90,6 +90,11 @@ our $default_projects_order = "project";
 # (only effective if this variable evaluates to true)
 our $export_ok = "++GITWEB_EXPORT_OK++";
 
+# hide repository from the list if this file exists
+# (the repository is still accessible, just not shown in the project list)
+# (only effective if this variable evaulates to true)
+our $hide_repo = "++GITWEB_HIDE_REPO++";
+
 # only allow viewing of repositories also shown on the overview page
 our $strict_export = "++GITWEB_STRICT_EXPORT++";
 
@@ -1796,7 +1801,8 @@ sub git_get_projects_list {
 				# we check related file in $projectroot
 				if ($check_forks and $subdir =~ m#/.#) {
 					$File::Find::prune = 1;
-				} elsif (check_export_ok("$projectroot/$filter/$subdir")) {
+				} elsif ((!$hide_repo or ! -e "$projectroot/$filter/$subdir/$hide_repo")
+				    and check_export_ok("$projectroot/$filter/$subdir")) {
 					push @list, { path => ($filter ? "$filter/" : '') . $subdir };
 					$File::Find::prune = 1;
 				}
@@ -1846,7 +1852,8 @@ sub git_get_projects_list {
 					next PROJECT;
 				}
 			}
-			if (check_export_ok("$projectroot/$path")) {
+			if ((!$hide_repo or ! -e "$projectroot/$path/$hide_repo")
+			    and check_export_ok("$projectroot/$path")) {
 				my $pr = {
 					path => $path,
 					owner => to_utf8($owner),

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux