Skip to content

Commit

Permalink
implement .nowatchman discovery in repo root
Browse files Browse the repository at this point in the history
Summary:
Implement .nowatchman check as required in the task

If .nowatchman is presented, not spawning watchman

As required, we will check .nowatchman under repo root, only .nowatchman under repo root will count.

Reviewed By: kmancini

Differential Revision: D49429032

fbshipit-source-id: f959f5bbd3e2e08e6bc888000491415829fc14f9
  • Loading branch information
Xinyi Wang authored and facebook-github-bot committed Sep 19, 2023
1 parent 9aba113 commit 623be74
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions watchman/cmds/watch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ bool find_project_root(
return false;
}

void check_no_watchman(w_string resolved_root) {
// check if .nowatchman exists under the resolved path
auto no_watchman_path = w_string::pathCat({resolved_root, ".nowatchman"});
if (w_path_exists(no_watchman_path.c_str())) {
CommandValidationError::throwf(
"resolve_projpath: the repository is configured to not enable watchman. "
"Found .nowatchman at {}",
no_watchman_path);
}
}

// For watch-project, take a root path string and resolve the
// containing project directory, then update the args to reflect
// that path.
Expand Down Expand Up @@ -235,6 +246,7 @@ static w_string resolve_projpath(
if (find_project_root(*root_files, resolvedpiece, relpiece)) {
relpath = relpiece.asWString();
resolved = resolvedpiece.asWString();
check_no_watchman(resolved);
args[1] = w_string_to_json(resolved);
return resolved;
}
Expand Down

0 comments on commit 623be74

Please sign in to comment.