Skip to content

Commit

Permalink
phabricator: do not look up .arcconfig across home directory
Browse files Browse the repository at this point in the history
Summary:
Defend against random files outside `HOME` (`TESTTMP`) like `/tmp/.arcconfig`
affecting behavior. The idea is similar to `GIT_CEILING_DIRECTORIES`.

Reviewed By: lmvasquezg

Differential Revision: D61672165

fbshipit-source-id: 1a7b40aa786f696d2241488eb9ac6ee74bd542ea
  • Loading branch information
quark-zju authored and facebook-github-bot committed Jan 28, 2025
1 parent 1a91509 commit 78a8a78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions eden/scm/sapling/ext/extlib/phabricator/arcconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ def loadforpath(path):
userconfig["_arcconfig_path"] = path
return userconfig
parent = os.path.dirname(path)
if parent == path:
# We have reached a root (e.g. "C:\\" on Windows).
if parent == path or path == homedir:
# We have reached a root (e.g. "C:\\" on Windows),
# or reached at homedir (set to TESTTMP in tests),
# do not look up further. This avoids random files
# in TMP affects test behavior unexpectedly.
break
path = parent

Expand Down
13 changes: 13 additions & 0 deletions eden/scm/tests/test-fb-ext-arcconfig.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@
$ echo '{"user": true}' > $HOME/.arcrc
$ hg debugarcconfig
{"_arcconfig_path": "$TESTTMP/repo", "hello": "world", "user": true}

# .arcconfig lookup is scoped at $HOME

$ cd
$ mkdir -p x/y
$ echo '{"foo": "bar"}' > x/.arcconfig
$ cd x/y
$ hg init
$ hg debugarcconfig
{"_arcconfig_path": "$TESTTMP/x", "foo": "bar", "user": true}
$ HOME=$PWD hg debugarcconfig
abort: no .arcconfig found
[255]

0 comments on commit 78a8a78

Please sign in to comment.