prompt: only name a task scope in a git work tree
The Telegram daemon runs in $HOME, not in a project; sp_task_scope_note would have called the scope "home". .git in the working directory is the signal. test_sessiontools: a plain temp directory gets no paragraph; test_engine still sees the note in the repository root.
This commit is contained in:
1 parent
eba6f71a2d
commit
fb3cacbb4c
2 files changed
+20
No files matched your search
@@ -855,6 +855,12 @@ sp_task_scope_note(struct sp_buf *out)
|
||||
base = strrchr(cwd, '/');
|
||||
if (base == NULL || base[1] == '\0')
|
||||
return 0;
|
||||
/*
|
||||
* Only a project tree gets a project scope. $HOME, ~/.hermes and a data
|
||||
* directory are not projects; a scope named "home" would be a lie.
|
||||
*/
|
||||
if (access(".git", F_OK) != 0)
|
||||
return 0;
|
||||
base++;
|
||||
return sp_buf_printf(out,
|
||||
"This working directory is the project \"%s\". For questions about "
|
||||
|
||||
@@ -183,6 +183,20 @@ main(void)
|
||||
CHECK(!contains(out.p, "sess-elsewhere"));
|
||||
sp_buf_clear(&out);
|
||||
|
||||
/* a directory that is not a git project gets no task-scope paragraph */
|
||||
{
|
||||
char back[512];
|
||||
struct sp_buf note;
|
||||
|
||||
CHECK(getcwd(back, sizeof(back)) != NULL);
|
||||
CHECK(chdir(dir) == 0);
|
||||
CHECK(sp_buf_init(¬e) == 0);
|
||||
CHECK(sp_task_scope_note(¬e) == 0);
|
||||
CHECK(note.len == 0);
|
||||
sp_buf_free(¬e);
|
||||
CHECK(chdir(back) == 0);
|
||||
}
|
||||
|
||||
/* missing query is an error, not a wildcard search */
|
||||
CHECK(search->run("{}", &out, search->ctx) == 0);
|
||||
CHECK(contains(out.p, "error: 'query' is required"));
|
||||
|
||||
Reference in new issue
Block a user