Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print issue tracker, maintainers and contributors in package banners #3215

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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