"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: reset committer name during rebase and histedit
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 23 Jul 2022 16:14:26 +0200

Download raw body.

Thread
Stefan Sperling <stsp@stsp.name> wrote:
> On Sat, Jul 23, 2022 at 03:57:57PM +0200, Omar Polo wrote:
> > the test_rebase_no_author_info fails if there is a ~/.gitconfig file.
> > overriding HOME is not feasible, and providing an empty one in the repo
> > is not ideal either because get_author() will fall back to the global
> > config if the local one doesn't have a author defined (and if
> > $GOT_AUTHOR is not defined.)
> > 
> > So, as discussed on irc add an undocumented env var,
> > GOT_IGNORE_GITCONFIG for the tests.  only that this breaks the commit
> > tests.  To work around that and to hopefully simplify future tests, diff
> > belows moves some variable definition from the global scope into
> > run_test: this way we can override them in functions without affecting
> > the following tests in the same file.
> 
> I don't think we should make the tests more complicated for this reason.
> Rather, we should change the tooling such that scripting it the way we
> need to becomes as easy as possible.

i'm not seeing how the proposed change would complicate the test.  my
only concern was that if we play with env variables in one test
function, that change will be visible for the other tests functions that
follows.

anyway, i forgot that we could change the values in a subshell, so it
could be further simplified to:

diff /home/op/w/got
commit - 2c8899b952f67f90ab3a26b4331491832fe93c8a
path + /home/op/w/got
blob - bd32f96c5071b834cc2b1478703442467b2cbfca
file + regress/cmdline/commit.sh
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -901,7 +901,8 @@ test_commit_gitconfig_author() {
 	(cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
 
 	echo "modified alpha" > $testroot/wt/alpha
-	(cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
+	(unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
+		 got commit -m 'test gitconfig author' > /dev/null)
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		test_done "$testroot" "$ret"
blob - 26f717faa35b5906f8abb7c9f459f633ebaa09dc
file + regress/cmdline/common.sh
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
@@ -23,6 +23,7 @@ export GOT_AUTHOR_8="flan_hac"
 export GOT_AUTHOR_11="flan_hacker"
 export GOT_LOG_DEFAULT_LIMIT=0
 export GOT_TEST_ROOT="/tmp"
+export GOT_IGNORE_GITCONFIG=1
 
 export MALLOC_OPTIONS=S
 
blob - 17e0a03100631d85b1f0e371cf6380a5c8c25fe3
file + regress/cmdline/rebase.sh
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
@@ -1597,8 +1597,8 @@ test_rebase_no_author_info() {
 		return 1
 	fi
 
-	unset GOT_AUTHOR
-	(cd $testroot/wt && got rebase newbranch > $testroot/stdout)
+	(unset GOT_AUTHOR && cd $testroot/wt && \
+		got rebase newbranch > $testroot/stdout)
 
 	(cd $testroot/repo && git checkout -q newbranch)
 	local new_commit1=`git_show_parent_commit $testroot/repo`