di-sukharev / opencommit

Generate conventional git commit messages with AI in 1 second 🤯🔫
https://www.npmjs.com/package/opencommit
MIT License
5.98k stars 318 forks source link

[Bug]: skip files depending on CWD #256

Open coffebar opened 1 year ago

coffebar commented 1 year ago

Opencommit Version

v3.0.3

Node Version

v20.6.0

NPM Version

9.8.1

What OS are you seeing the problem on?

Other Linux Distro

What happened?

When I use dotfiles bare repo, oco does not detect git when CWD is not in the top level of the work-tree.

Expected Behavior

Generate a commit message

Current Behavior

~ oco │ └ No changes detected

Possible Solution

No response

Steps to Reproduce

  1. Create bare repo REPODIR
  2. WORKDIR is your directory with files
  3. cd to the inner directory inside WORKDIR/
  4. add changes to commit (git add)
  5. run GIT_WORK_TREE=/absolute-path/WORKDIR GIT_DIR=/absolute-path/REPODIR oco

Note: it will work if you do the same except step 3 (if your CWD is WORKDIR)

Relevant log output

No response

coffebar commented 1 year ago

I see this command is used to get staged files: git --name-only --cached --relative

I have tested it on my repo and find out that if my CWD is below that dir of the changed file, it will not show that file.

For example structure is:

 - Readme.md *
 - SRC/
 - --Files/

In the root directory - git --name-only --cached --relative shows Readme.md

in Files or in SRC directory - nothing.

If remove "--relative" param - it will show path from anywhere relative to the WorkingDirectory

github-actions[bot] commented 11 months ago

Stale issue message

di-sukharev commented 7 months ago

@coffebar was this actually completed, do you want to reopen?

coffebar commented 7 months ago

not sure, currently not using

di-sukharev commented 7 months ago

thanks