sapling/eden/scm/tests/test-hgext-logginghelper.t
Thomas Orozco 6676a7a476 logginghelper: use repo basename as repo name
Summary:
When we don't provide a repo name, scm_telem_log will run `hg config` to try
and get the path, and fall back to using the basename of the repo directory.

However, this is a bit undesirable, because if we ran this code we already
checked the path, so the repo URL isn't going to magically materialize once `hg
config` asks for it, which means we make a completely redundant call to hg from
scm_telem_log.

By just doing this in logginghelper, we avoid this extra roundtrip.

Reviewed By: StanislavGlebik

Differential Revision: D21572027

fbshipit-source-id: 58e5ab2e3e525edef1ecde039cd968eab8d89172
2020-05-15 03:02:00 -07:00

40 lines
867 B
Perl

#require jq
#chg-compatible
$ . "$TESTDIR/library.sh"
$ enable logginghelper
$ enable sampling
$ setconfig sampling.key.logginghelper=logginghelper
$ hg init repo123
$ cd repo123
$ export SCM_SAMPLING_FILEPATH="$TESTTMP/sample"
Check we got the repository name from the local path
$ hg status
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
repo123
$ rm "$SCM_SAMPLING_FILEPATH"
Check that it doesn't matter where we are in the repo
$ mkdir foobar
$ cd foobar
$ hg status
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
repo123
$ rm "$SCM_SAMPLING_FILEPATH"
$ cd ..
Check we got the repository name from the remote path
$ setconfig paths.default=ssh://foo.com//bar/repo456
$ hg status
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
repo456
$ rm "$SCM_SAMPLING_FILEPATH"