Skip to content

[BUG] initShadowGit can use an unwanted init.templatedir #8628

@xverges

Description

@xverges

Problem (one or two sentences)

By default, git init uses whatever is configured in the user's $(git config --global init.templateDir). This may include hooks that the shadow git should not be triggering.

Context (who is affected and when)

Users of https://pre-commit.com/ that have updated their init.templatedir may see that the hooks they have defined are triggered on their workspace by commands on the shadow git.

There are others scenarios where side effects of using an unknow init.templatedir could have.

Reproduction steps

  1. Create and setup an init.templatedir that causes hooks to be triggered. This can be done with
    1.1) Install pre-commit (brew install pre-commit in OSX)
    1.2) Setup a git int.templatedir and execute pre-commit init-templatediron it
  2. Create an empty project for Roo-Code and run git init
  3. Remove the .git/hooks/pre-commit file, so that the project does not have a pre-commit hook
  4. Add a .pre-commit-config.yaml to the project:
repos:
  - repo: local
    hooks:
      - id: create-timestamp-file
        name: Create timestamp file
        entry: bash -c 'pwd > "$(date +%Y-%m-%d_%H-%M-%S).txt"'
        language: system
        pass_filenames: false
        always_run: true
  1. git add .pre-commit-config.yaml and git commit -m "initial commit: nothing is triggered, as we removed the pre-commit hook
  2. Perform any action that causes the the shadow git to be created and commited to

Expected result

The pre-commit hook is not triggered

Actual result

The pre-commit hook is triggered and we see its effects in the project (a new file with the time stamp)

Variations tried (optional)

No response

App Version

3.28.16

API Provider (optional)

None

Model Used (optional)

No response

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Issue [In Progress]

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions