Skip to content

Commit d971fd3

Browse files
committed
fix(publish): handle null cwd in process capture and detect git repos via git
2 parents 743dd3d + 1f63c6b commit d971fd3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/commands/PublishCommand.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,12 @@ namespace vix::commands
435435
if (pid == 0)
436436
{
437437
// child
438-
if (chdir(cwd->c_str()) != 0)
438+
if (cwd)
439439
{
440-
_exit(127);
440+
if (chdir(cwd->c_str()) != 0)
441+
_exit(127);
441442
}
443+
442444
dup2(outPipe[1], STDOUT_FILENO);
443445
dup2(errPipe[1], STDERR_FILENO);
444446

@@ -456,7 +458,6 @@ namespace vix::commands
456458
execvp(argv[0], argv.data());
457459
_exit(127);
458460
}
459-
460461
// parent
461462
close(outPipe[1]);
462463
close(errPipe[1]);
@@ -725,8 +726,11 @@ namespace vix::commands
725726

726727
static bool is_git_repo(const fs::path &dir)
727728
{
728-
std::error_code ec;
729-
return fs::exists(dir / ".git", ec);
729+
const auto r = run_process_capture(
730+
{"git", "rev-parse", "--is-inside-work-tree"},
731+
dir);
732+
733+
return r.exitCode == 0 && trim_copy(r.out) == "true";
730734
}
731735

732736
static bool command_exists_on_path(const std::string &exe)

0 commit comments

Comments
 (0)