sapling/eden/scm/tests/test-git-push-default-push.t
Mark Shroyer ac6d40c320 git: respect 'default-push' path if present (#469)
Summary:
git: respect 'default-push' path if present
In non-Git mode, 'hg push' (without an explicit path) pushes to the
'default-push' path if present, falling back to the 'default' path.

In Git mode, 'sl push' (without an explicit path) always pushes to the 'default'
path. 'default-push' is ignored.

Teach Git mode to push to 'default-push' if present, similar to how it works in
non-Git mode.

This commit only affects 'sl push'. 'sl pr submit' still ignores the
'default-push' path.

Pull Request resolved: https://github.com/facebook/sapling/pull/469

Test Plan: $ (cd tests && python run-tests.py test-git-push-default-push.t)

Reviewed By: muirdm

Differential Revision: D43336914

Pulled By: quark-zju

fbshipit-source-id: f11c45fb2bd8678b6be7294bf15359131db0ee2e
2023-02-17 12:04:00 -08:00

42 lines
1.1 KiB
Perl

#require git no-windows
#debugruntest-compatible
$ . $TESTDIR/git.sh
Initialize the server repos.
$ git init -q --bare -b main repo-1.git
$ git init -q --bare -b main repo-2.git
Initialize the Sapling repo.
$ hg clone -q --git "$TESTTMP/repo-1.git" client-repo
$ cd client-repo
$ hg paths --add default-push "$TESTTMP/repo-2.git"
$ touch testfile
$ hg add testfile
$ hg commit testfile -m testcommit
Pushing without specifying a path pushes to the 'default-push' path.
$ hg push -q -r . --to main --create
$ GIT_DIR="$TESTTMP/repo-1.git" git log --pretty=format:%s%n
fatal: your current branch 'main' does not have any commits yet
[128]
$ GIT_DIR="$TESTTMP/repo-2.git" git log --pretty=format:%s%n
testcommit
After deleting the 'default-push' path,
pushing without specifying a path pushes to the 'default' path
$ hg paths --delete default-push
$ hg push -q -r . --to main --create
$ GIT_DIR="$TESTTMP/repo-1.git" git log --pretty=format:%s%n
testcommit
$ GIT_DIR="$TESTTMP/repo-2.git" git log --pretty=format:%s%n
testcommit