From ed429c9f6f49fbb52d74daaccf8ed9859efefa28 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 20 Mar 2018 20:00:14 -0400 Subject: [PATCH] docs: repo-hooks: fix cwd details The hooks are run from the top of the manifest checkout, not from the individual git repos. It's up to individual hooks to chdir as needed. Change-Id: I53325e0c3dcaa9c250b02b223e78d238d2cbd36d --- docs/repo-hooks.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/repo-hooks.md b/docs/repo-hooks.md index c8eb945f..76113cc9 100644 --- a/docs/repo-hooks.md +++ b/docs/repo-hooks.md @@ -61,9 +61,14 @@ not be too verbose. A short summary is nice, and some status information when long running operations occur, but long/verbose output should be used only if the hook ultimately fails. -The hook runs from the top level of the git repo where the operation is started. -e.g. If you're in the git repo `src/foo/`, that is where the hook runs, even if -the `repo` command was started from a subdir like `src/foo/bar/`. +The hook runs from the top level of the repo client where the operation is +started. +For example, if the repo client is under `~/tree/`, then that is where the hook +runs, even if you ran repo in a git repository at `~/tree/src/foo/`, or in a +subdirectory of that git repository in `~/tree/src/foo/bar/`. +Hooks frequently start off by doing a `os.chdir` to the specific project they're +called on (see below) and then changing back to the original dir when they're +finished. Python's `sys.path` is modified so that the top of repohooks directory comes first. This should help simplify the hook logic to easily allow importing of