@@ -489,24 +489,25 @@ def commit():
489489 f .write ("# comment\n " )
490490 assert commit () == "msg"
491491
492+ def _auto_commit (self , capsys , git_repo ):
493+ with (
494+ os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
495+ patch ("sys.argv" , self .args + ["-a" ]),
496+ pytest .raises (SystemExit ) as excinfo ,
497+ chdir (git_repo .path ),
498+ ):
499+ self .script ()
500+ assert excinfo .value .code == 0
501+ out , err = capsys .readouterr ()
502+ assert err == out == ""
503+ message = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
504+ return message [0 ]
505+
492506 def test_generated_commit_summaries (self , capsys , repo , make_git_repo ):
493507 git_repo = make_git_repo (repo .location )
494508 repo .create_ebuild ("cat/pkg-0" )
495509 git_repo .add_all ("cat/pkg-0" )
496-
497- def commit ():
498- with (
499- os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
500- patch ("sys.argv" , self .args + ["-a" ]),
501- pytest .raises (SystemExit ) as excinfo ,
502- chdir (git_repo .path ),
503- ):
504- self .script ()
505- assert excinfo .value .code == 0
506- out , err = capsys .readouterr ()
507- assert err == out == ""
508- message = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
509- return message [0 ]
510+ commit = partial (self ._auto_commit , capsys , git_repo )
510511
511512 # initial package import
512513 repo .create_ebuild ("cat/newpkg-0" )
@@ -630,9 +631,31 @@ def commit():
630631 shutil .rmtree (pjoin (git_repo .path , "newcat/pkg" ))
631632 assert commit () == "newcat/pkg: treeclean"
632633
634+ def test_generated_commit_summaries_acounts (self , capsys , repo , make_git_repo ):
635+ git_repo = make_git_repo (repo .location )
636+ repo .create_ebuild ("cat/pkg-0" )
637+ git_repo .add_all ("cat/pkg-0" )
638+ commit = partial (self ._auto_commit , capsys , git_repo )
639+
640+ # GLEP 81 accounts name the identifier they allocate
641+ repo .create_ebuild ("acct-user/newuser-0" , acct_user_id = 123 )
642+ assert commit () == "acct-user/newuser: add user 123"
643+
644+ repo .create_ebuild ("acct-group/newgroup-0" , acct_group_id = 456 )
645+ assert commit () == "acct-group/newgroup: add group 456"
646+
647+ # a dynamically allocated id has nothing to name
648+ repo .create_ebuild ("acct-user/dynamic-0" , acct_user_id = - 1 )
649+ assert commit () == "acct-user/dynamic: new package, add 0"
650+
651+ # only for a new package, not a version added to an existing one
652+ repo .create_ebuild ("acct-user/newuser-1" , acct_user_id = 123 )
653+ assert commit () == "acct-user/newuser: add 1"
654+
633655 def test_generated_commit_summaries_keywords (self , capsys , make_repo , make_git_repo ):
634656 repo = make_repo (arches = ["amd64" , "arm64" , "ia64" , "x86" ])
635657 git_repo = make_git_repo (repo .location )
658+ commit = partial (self ._auto_commit , capsys , git_repo )
636659 pkgdir = os .path .dirname (repo .create_ebuild ("cat/pkg-0" ))
637660 with open (pjoin (pkgdir , "metadata.xml" ), "w" ) as f :
638661 f .write (
@@ -648,20 +671,6 @@ def test_generated_commit_summaries_keywords(self, capsys, make_repo, make_git_r
648671 )
649672 git_repo .add_all ("cat/pkg-0" )
650673
651- def commit ():
652- with (
653- os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
654- patch ("sys.argv" , self .args + ["-a" ]),
655- pytest .raises (SystemExit ) as excinfo ,
656- chdir (git_repo .path ),
657- ):
658- self .script ()
659- assert excinfo .value .code == 0
660- out , err = capsys .readouterr ()
661- assert err == out == ""
662- message = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
663- return message [0 ]
664-
665674 # keyword version
666675 repo .create_ebuild ("cat/pkg-0" , keywords = ["~amd64" ])
667676 assert commit () == "cat/pkg: keyword 0 for ~amd64"
@@ -711,6 +720,7 @@ def commit():
711720 def test_metadata_summaries (self , capsys , repo , make_git_repo ):
712721 git_repo = make_git_repo (repo .location )
713722 pkgdir = os .path .dirname (repo .create_ebuild ("cat/pkg-0" ))
723+ commit = partial (self ._auto_commit , capsys , git_repo )
714724 # stub metadata
715725 with open (pjoin (pkgdir , "metadata.xml" ), "w" ) as f :
716726 f .write (
@@ -729,20 +739,6 @@ def test_metadata_summaries(self, capsys, repo, make_git_repo):
729739 )
730740 git_repo .add_all ("cat/pkg-0" )
731741
732- def commit ():
733- with (
734- os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
735- patch ("sys.argv" , self .args + ["-a" ]),
736- pytest .raises (SystemExit ) as excinfo ,
737- chdir (git_repo .path ),
738- ):
739- self .script ()
740- assert excinfo .value .code == 0
741- out , err = capsys .readouterr ()
742- assert err == out == ""
743- message = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
744- return message [0 ]
745-
746742 # add yourself
747743 with open (pjoin (pkgdir , "metadata.xml" ), "w" ) as f :
748744 f .write (
0 commit comments