[GH-ISSUE #1538] GitProcessor: run git branch from a specified directory instead of working directory #655

Open
opened 2026-03-04 02:16:45 +03:00 by kerem · 1 comment
Owner

Originally created by @root-talis on GitHub (Mar 10, 2021).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1538

When running a script from cron it is very possible that the working directory will not match the script directory. In this case, instead of logging the git version, GitProcessor logs this:

fatal: not a git repository (or any of the parent directories): .git
[2021-03-10 10:26:46] channel.LEVEL: Something happened [] {"git":[]}

This happens every time something is logged. Not only this is unhelpful, but it is also annoying because analyzing such logs becomes an issue: fatal is a keyword by which one might want to filter their logs.

It would be nice to make it possible to specify the directory in which git branch should be run, for example via a configuration value passed to the constructor.

Originally created by @root-talis on GitHub (Mar 10, 2021). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1538 When running a script from cron it is very possible that the working directory will not match the script directory. In this case, instead of logging the git version, GitProcessor logs this: ``` fatal: not a git repository (or any of the parent directories): .git [2021-03-10 10:26:46] channel.LEVEL: Something happened [] {"git":[]} ``` This happens every time something is logged. Not only this is unhelpful, but it is also annoying because analyzing such logs becomes an issue: `fatal` is a keyword by which one might want to filter their logs. It would be nice to make it possible to specify the directory in which `git branch` should be run, for example via a configuration value passed to the constructor.
Author
Owner

@Seldaek commented on GitHub (Apr 4, 2021):

I guess as a workaround you could make sure to call $gitProcessor([]) early in your process before you change the directory, to make sure the cache is populated.

But otherwise if you like to send a PR adding a new $path option, that sounds good to me.

<!-- gh-comment-id:813044848 --> @Seldaek commented on GitHub (Apr 4, 2021): I guess as a workaround you could make sure to call $gitProcessor([]) early in your process before you change the directory, to make sure the cache is populated. But otherwise if you like to send a PR adding a new $path option, that sounds good to me.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#655
No description provided.