summaryrefslogtreecommitdiffstats
path: root/src/commands/readme
blob: cd9632f5fa76dd7d424cc289671c527df0c845be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
use strict;
use warnings;

use lib $ENV{GL_LIBDIR};
use Gitolite::Easy;

# README.html files work similar to "description" files. For further
# information see
#   https://www.kernel.org/pub/software/scm/git/docs/gitweb.html
# under "Per-repository gitweb configuration".

=for usage
Usage:    ssh git@host readme <repo>
          ssh git@host readme <repo> rm
          cat <filename> | ssh git@host readme <repo> set

Show, remove or set the README.html file for repo.

You need to have write access to the repo and the 'writer-is-owner' option
must be set for the repo, or it must be a user-created ('wild') repo and you
must be the owner.
=cut

usage() if not @ARGV or @ARGV < 1 or $ARGV[0] eq '-h';

my $repo = shift;
my $op = shift || '';
usage() if $op and $op ne 'rm' and $op ne 'set';
my $file = 'README.html';

#<<<
_die "you are not authorized" unless
    ( not $op and can_read($repo) )   or
    (     $op and owns($repo) )       or
    (     $op and can_write($repo)    and option( $repo, 'writer-is-owner' ) );
#>>>

if ( $op eq 'rm' ) {
    unlink "$rc{GL_REPO_BASE}/$repo.git/$file";
} elsif ( $op eq 'set' ) {
    textfile( file => $file, repo => $repo, prompt => '' );
} else {
    print textfile( file => $file, repo => $repo );
}

__END__

The WRITER_CAN_UPDATE_README option is gone now; it applies to all the repos
in the system.  Much better to add 'option writer-is-owner = 1' to repos or
repo groups that you want this to apply to.

This option is meant to cover desc, readme, and any other repo-specific text
file, so it's also a blunt instrument, though in a different dimension :-)