plandex-ai/plandex · warning
no commits found before time: %s
Error message
no commits found before time: %s
What it means
GetLatestCommitShaBeforeTime looks up the most recent commit whose timestamp is before a given time and parses the sha from git log output split on '@@|@@'. When the command output is empty — meaning git found no matching commits — the function returns this error with the formatted cutoff time. It signals 'nothing in history before this timestamp' rather than an exec failure.
Source
Thrown at app/server/db/git.go:258
cmd := exec.Command("git", "-C", dir, "log", "-n", "1",
"--before="+gitFormattedTime,
"--pretty=%h@@|@@%B@>>>@")
log.Printf("ADMIN - Executing command: %s", cmd.String())
res, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("error getting latest commit before time for dir: %s, err: %v, output: %s", dir, err, string(res))
}
// log.Printf("ADMIN - git log res: %s", string(res))
output := strings.TrimSpace(string(res))
// history := processGitHistoryOutput(strings.TrimSpace(string(res)))
// log.Printf("ADMIN - History: %v", history)
if output == "" {
return "", fmt.Errorf("no commits found before time: %s", before.Format("2006-01-02T15:04:05Z"))
}
sha = strings.Split(output, "@@|@@")[0]
return sha, nil
}
func (repo *GitRepo) GitListBranches() ([]string, error) {
orgId := repo.orgId
planId := repo.planId
dir := getPlanDir(orgId, planId)
var out bytes.Buffer
cmd := exec.Command("git", "branch", "--format=%(refname:short)")
cmd.Dir = dir
cmd.Stdout = &out
err := cmd.Run()
if err != nil {View on GitHub (pinned to e2d772072e)
Solutions
- Verify the `before` timestamp is in the expected timezone/format (compare against `git log --date=iso` output for the repo).
- Call only with times after the repo's earliest commit; clamp to the first commit's date if the caller needs 'the oldest available'.
- Handle the empty-history case explicitly in the caller (treat as 'no prior version') instead of treating it as an exception where appropriate.
- If the repo should have history, check you are pointing at the right repo dir and that HEAD exists (`git log -1`).
Example fix
// before
sha, err := GetLatestCommitShaBeforeTime(repoDir, before)
// after (guard in caller)
firstCommitTime := getFirstCommitTime(repoDir)
if before.Before(firstCommitTime) {
return ErrNoCommitBeforeTime // handle as expected-empty, not failure
}
sha, err := GetLatestCommitShaBeforeTime(repoDir, before) Defensive patterns
Strategy: fallback
Validate before calling
func hasHistoryBefore(repoDir string, before time.Time) bool {
out, err := exec.Command("git", "-C", repoDir, "rev-list", "-n", "1", "--before="+before.Format(time.RFC3339), "HEAD").Output()
return err == nil && len(out) > 0
} Try / catch
sha, err := GetLatestCommitShaBeforeTime(repoDir, before)
if err != nil && strings.HasPrefix(err.Error(), "no commits found before time") {
// expected for very old cutoffs or empty repos: fall back to oldest commit or empty diff
sha, err = getOldestCommitSha(repoDir)
if err != nil {
return "", nil // no history at all
}
} Prevention
- Validate the timezone/format of `before` timestamps before calling (UTC vs local confusion is the top cause).
- Treat empty history as a normal, expected case in callers rather than an exception.
- Check the repo actually has commits (`git log -1`) before time-based queries.
- Clamp cutoffs to at least the repo's first commit time.
When it happens
Trigger: Calling GetLatestCommitShaBeforeTime with a `before` time earlier than the repository's first commit, or on a repo with no commits at all; also when the git log invocation silently produces no output (empty/corrupt repo).
Common situations: Caller passes a wrong timezone-formatted time (e.g. an unconverted local vs UTC time making `before` land before repo creation); brand-new plan repo with no history; caller miscomputes the cutoff for pagination/rewind.
Related errors
- error getting git root: %s
- error getting git status: %s
- error getting files in git repo: %s
- error getting untracked files in git repo: %s
- failed to commit changes: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/a0fddad2779b1e40.
Report an issue: GitHub.