summaryrefslogtreecommitdiffstats
path: root/src/commands/desc
blob: 4a4bf20a3fc21e6286075b4e5f625dd6d80d3dc1 (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
#!/usr/bin/perl
use strict;
use warnings;

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

=for usage
Usage:    ssh git@host desc <repo>
          ssh git@host desc <repo> <description string>

Show or set description 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 $text = join( " ", @ARGV );
my $file = 'description';

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

$text
  ? textfile( file => $file, repo => $repo, text => $text )
  : print textfile( file => $file, repo => $repo );

__END__

kernel.org needs 'desc' to be available to people who have "RW" or above, not
just the "creator".  In fact they need it for non-wild repos so there *is* no
creator.  To accommodate this, we created the WRITER_CAN_UPDATE_DESC rc
variable.

However, that has turned out to be a bit of a blunt instrument for people with
different types of wild repos -- they don't want to apply this to all of them.
It seems easier to do this as an option, so you may have it for one set of
"repo ..." and not have it for others.  And if you want it for the whole
system you'd just put it under "repo @all".

The new 'writer-is-owner' 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 :-)