Commit Graph

4 Commits

Author SHA1 Message Date
brian m. carlson
639a9552de
Interpret relative hook paths as relative to working tree
Git specifies that relative hook paths are specified relative to the
working tree in a non-bare repository.  However, we were interpreting it
relative to the working directory, which meant that we could install
hooks in an undesired place if the user was in a subdirectory of the
repository.  Fix this by installing relative to the root of the working
tree as Git does.
2019-11-21 17:19:55 +00:00
Taylor Blau
f7b1a5c8f8 tools/filetools.go: teach ExpandPath() to do path expansion
In order to expand strings of the form "~/path/to/hooks" into something
like "/home/ttaylorr/path/to/hooks", let's introduce the
tools.ExpandPath() function to do just that.

tools.ExpandPath() inspects the first character of the given string to
see if it begins with a "~" (indicating the presence of a home
directory.

If there is, see also if it refers to a specific "~user", and expand
appropriately.

To ensure that we can run the tests in tools/filetool_test.go in a
platform-independent manner, let's ensure that the results are
_semantically_ equal by first passing them through filepath.ToSlash().

We'll use this in the following commit in order to perform path
expansion on the value of core.hooksPath.
2018-08-30 16:59:33 -04:00
Taylor Blau
de9152049c t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
Taylor Blau
219b7e0a3d t: prefix all existing tests with t- 2018-07-09 16:24:25 -05:00