sapling/eden/scm/tests/test-fb-hgext-scm-prompt-git.t
Jan Mazur 1ca5f6bfae quiet git init command not to print out hint
Summary:
Git client was updated and it started outputting a hint that breaks our tests. It has no meaning in tests so just quiet it.

```
➜  fbcode git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in /data/users/mzr/fbsource/fbcode/.git/
```

Reviewed By: StanislavGlebik

Differential Revision: D27232853

fbshipit-source-id: 683ebebb36049adb758e7c26f843f12159a45301
2021-03-23 02:28:52 -07:00

99 lines
1.9 KiB
Perl

#chg-compatible
Initialize scm prompt
$ . $TESTDIR/../contrib/scm-prompt.sh
$ cmd() {
> "$@"
> _scm_prompt "(%s)\n"
> }
$ git() {
> command git -c init.defaultBranch=master "$@"
> }
$ quietcmd() {
> "$@" &> /dev/null
> _scm_prompt "(%s)\n"
> }
Set env to make commands repeatable
$ GIT_AUTHOR_NAME="Test User"
$ export GIT_AUTHOR_NAME
$ GIT_AUTHOR_EMAIL="test@user.org"
$ export GIT_AUTHOR_EMAIL
$ GIT_AUTHOR_DATE="2006-07-03 17:18:43 +0200"
$ export GIT_AUTHOR_DATE
$ GIT_COMMITTER_NAME="Test User"
$ export GIT_COMMITTER_NAME
$ GIT_COMMITTER_EMAIL="test@user.org"
$ export GIT_COMMITTER_EMAIL
$ GIT_COMMITTER_DATE="2006-07-03 17:18:43 +0200"
$ export GIT_COMMITTER_DATE
Outside of a repo, should have no output
$ _scm_prompt
Set up repo
$ git init -q repo
$ cd repo
$ _scm_prompt "%s\n"
master
$ cmd git commit -q --allow-empty -m "Initial empty commit"
(master)
Test basics
$ echo a > a
$ git add a
$ cmd git commit -qm "aa"
(master)
$ cmd git checkout -q "HEAD^"
(1fed3389)
Test rebase
$ cmd git checkout -q -b work "master^"
(work)
$ echo b > a
$ git add a
$ cmd git commit -qm "ba"
(work)
$ quietcmd git rebase master
(eef45076|REBASE*|work) (glob)
$ cmd git rebase --abort
(work)
$ quietcmd git rebase --merge master
(eef45076|REBASE-*|work) (glob)
$ cmd git rebase --abort
(work)
Test more advanced workflows
$ git format-patch "HEAD^" --stdout > .git/patch-ba
$ quietcmd git am < .git/patch-ba
(work|AM)
$ cmd git am --abort
(work)
$ echo c > a
$ cmd git commit -qam "ca"
(work)
$ quietcmd git revert eef4507
(work|REVERTING)
$ cmd git revert --abort
(work)
$ quietcmd git cherry-pick eef4507
(work|CHERRY-PICKING)
$ cmd git cherry-pick --abort
(work)
$ quietcmd git merge eef4507
(work|MERGE)
$ cmd git merge --abort
(work)
$ cmd git bisect start
(work|BISECT)
$ cmd git bisect reset
Already on 'work'
(work)