Skip to content

Commit

Permalink
Improve default package banners
Browse files Browse the repository at this point in the history
If available, print the issue tracker URL as part of the default package
banner. Also, if the list of package maintainers is non-empty and different
from the list of package authors, always print it.

Both changes are meant to help users to identify whom to contact about issues.

Finally, also list pure contributors (neither author nor maintainer) in
default package banner.
  • Loading branch information
fingolfin committed Jan 22, 2019
1 parent f56a68c commit 8bb3398
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 27 deletions.
45 changes: 31 additions & 14 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ InstallGlobalFunction( IsPackageMarkedForLoading, function( name, version )
#F DefaultPackageBannerString( <inforec> )
##
InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
local len, sep, i, str, authors, role, fill, person;
local len, sep, i, str, authors, maintainers, contributors, printPersons;

# Start with a row of `-' signs.
len:= SizeScreen()[1] - 3;
Expand Down Expand Up @@ -1114,19 +1114,13 @@ InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
fi;
Add( str, '\n' );

# Add info about the authors if there are authors;
# otherwise add maintainers.
if IsBound( inforec.Persons ) then
authors:= Filtered( inforec.Persons, x -> x.IsAuthor );
role:= "by ";
if IsEmpty( authors ) then
authors:= Filtered( inforec.Persons, x -> x.IsMaintainer );
role:= "maintained by ";
fi;
# Add info about the authors and/or maintainers
printPersons := function( role, persons )
local fill, person;
fill:= ListWithIdenticalEntries( Length(role), ' ' );
Append( str, role );
for i in [ 1 .. Length( authors ) ] do
person:= authors[i];
for i in [ 1 .. Length( persons ) ] do
person:= persons[i];
Append( str, person.FirstNames );
Append( str, " " );
Append( str, person.LastName );
Expand All @@ -1135,9 +1129,9 @@ InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
elif IsBound( person.Email ) then
Append( str, Concatenation( " (", person.Email, ")" ) );
fi;
if i = Length( authors ) then
if i = Length( persons ) then
Append( str, ".\n" );
elif i = Length( authors )-1 then
elif i = Length( persons )-1 then
if i = 1 then
Append( str, " and\n" );
else
Expand All @@ -1149,6 +1143,22 @@ InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
Append( str, fill );
fi;
od;
end;
if IsBound( inforec.Persons ) then
authors:= Filtered( inforec.Persons, x -> x.IsAuthor );
if not IsEmpty( authors ) then
printPersons( "by ", authors );
fi;
contributors:= Filtered( inforec.Persons, x -> not x.IsAuthor and not x.IsMaintainer );
if not IsEmpty( contributors ) then
Append( str, "with contributions by:\n");
printPersons( " ", contributors );
fi;
maintainers:= Filtered( inforec.Persons, x -> x.IsMaintainer );
if not IsEmpty( maintainers ) and authors <> maintainers then
Append( str, "maintained by:\n");
printPersons( " ", maintainers );
fi;
fi;

# Add info about the home page of the package.
Expand All @@ -1158,6 +1168,13 @@ InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
Append( str, "\n" );
fi;

# Add info about the issue tracker of the package.
if IsBound( inforec.IssueTrackerURL ) then
Append( str, "Report issues at " );
Append( str, inforec.IssueTrackerURL );
Append( str, "\n" );
fi;

# temporary hack, in some package names with umlauts are in HTML encoding
str := Concatenation(sep, RecodeForCurrentTerminal(str), sep);
str:= ReplacedString( str, "&auml;", RecodeForCurrentTerminal("ä") );
Expand Down
108 changes: 95 additions & 13 deletions tst/testinstall/package.tst
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ gap> Display(DefaultPackageBannerString(rec()));
-----------------------------------------------------------------------------


#
#
gap> pkginfo := rec(
> PackageName := "TestPkg",
> Version := "1.0",
> PackageWWWHome := "https://www.gap-system.org",
> PackageDoc := [ rec( LongTitle := "A test package" ) ],
> Persons := [ rec( IsAuthor := true,
> IsMaintainer := true,
> FirstNames := "Lord",
> LastName := "Vader",
> WWWHome := "https://www.gap-system.org/~darth"
> ) ]);;

#
# just one author & maintainer
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
Expand All @@ -73,39 +74,120 @@ Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


#
gap> Add(pkginfo.Persons, rec( IsAuthor := true, FirstNames := "Luke",
> LastName := "Skywalker", Email := "luke.skywalker@gap-system.org" ));
# add a maintainer who is not an author
gap> Add(pkginfo.Persons, rec( IsAuthor := false, IsMaintainer := true,
> FirstNames := "Luke", LastName := "Skywalker",
> Email := "luke.skywalker@gap-system.org" ));
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
by Lord Vader (https://www.gap-system.org/~darth).
maintained by:
Lord Vader (https://www.gap-system.org/~darth) and
Luke Skywalker (luke.skywalker@gap-system.org).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


# add an author who is not a maintainer
gap> Add(pkginfo.Persons, rec( IsAuthor := true, IsMaintainer := false,
> FirstNames := "Leia", LastName := "Organa" ));
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
by Lord Vader (https://www.gap-system.org/~darth) and
Leia Organa.
maintained by:
Lord Vader (https://www.gap-system.org/~darth) and
Luke Skywalker (luke.skywalker@gap-system.org).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


#
gap> Add(pkginfo.Persons, rec( IsAuthor := true, FirstNames := "Leia", LastName := "Organa" ));
# add a contributor
gap> Add(pkginfo.Persons, rec( IsAuthor := false, IsMaintainer := false,
> FirstNames := "Yoda", LastName := "",
> WWWHome := "https://www.gap-system.org/~yoda"));
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
by Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org), and
by Lord Vader (https://www.gap-system.org/~darth) and
Leia Organa.
with contributions by:
Yoda (https://www.gap-system.org/~yoda).
maintained by:
Lord Vader (https://www.gap-system.org/~darth) and
Luke Skywalker (luke.skywalker@gap-system.org).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


#
# test what happens if all are authors and maintainers
gap> for p in pkginfo.Persons do p.IsAuthor:=true; p.IsMaintainer:=true; od;
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
by Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org),
Leia Organa, and
Yoda (https://www.gap-system.org/~yoda).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


# test what happens if all are authors but not maintainers
gap> for p in pkginfo.Persons do p.IsAuthor:=true; p.IsMaintainer:=false; od;
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
by Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org),
Leia Organa, and
Yoda (https://www.gap-system.org/~yoda).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


# test what happens if all are maintainers but not authors
gap> for p in pkginfo.Persons do p.IsAuthor:=false; p.IsMaintainer:=true; od;
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
maintained by Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org), and
Leia Organa.
maintained by:
Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org),
Leia Organa, and
Yoda (https://www.gap-system.org/~yoda).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


# test what happens if all are contributors
gap> for p in pkginfo.Persons do p.IsAuthor:=false; p.IsMaintainer:=false; od;
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
with contributions by:
Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org),
Leia Organa, and
Yoda (https://www.gap-system.org/~yoda).
Homepage: https://www.gap-system.org
-----------------------------------------------------------------------------


# test IssueTrackerURL
gap> pkginfo.IssueTrackerURL := "https://issues.gap-system.org/";;
gap> Display(DefaultPackageBannerString(pkginfo));
-----------------------------------------------------------------------------
Loading TestPkg 1.0 (A test package)
with contributions by:
Lord Vader (https://www.gap-system.org/~darth),
Luke Skywalker (luke.skywalker@gap-system.org),
Leia Organa, and
Yoda (https://www.gap-system.org/~yoda).
Homepage: https://www.gap-system.org
Report issues at https://issues.gap-system.org/
-----------------------------------------------------------------------------


Expand Down

0 comments on commit 8bb3398

Please sign in to comment.