Skip to content

fix: getGitEmail() should accept a directory parameter for cwd consistency #44

@jim80net

Description

@jim80net

Problem

In src/services/tags.ts, getGitEmail() calls execSync("git config user.email") without passing cwd, so it uses the process working directory rather than the project directory.

The recently added getGitRemoteUrl() correctly passes { cwd: directory }, creating an inconsistency between the two functions that have the same shape.

Impact

In practice this is low-risk because git user email is typically global (~/.gitconfig), but if a user has a per-repo email override, the wrong email could be read when the process working directory differs from the project directory.

Suggested Fix

Add a directory parameter to getGitEmail() and pass it as cwd:

export function getGitEmail(directory?: string): string | null {
  try {
    const email = execSync("git config user.email", {
      cwd: directory,
      encoding: "utf-8",
      stdio: ["pipe", "pipe", "pipe"],
    }).trim();
    return email || null;
  } catch {
    return null;
  }
}

Update the call site in getUserTag() (or pass directory through getTags).

Context

Found during systems review of PR #43.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions