-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior of simpleGit.log when trying to get commits before a tag #956
Comments
Hi, thanks for opening the detailed issue. The To explicitly set the bounds of the log, use const git = simpleGit({ trimmed: true });
const initialCommit = await git.raw('rev-list', '--max-parents=0', 'HEAD');
await git.log({
from: from ?? initialCommit,
to: to ?? 'HEAD',
symmetric: false,
}); |
Thank you for the suggestion. This works great!
(optional) Consider adding a warning when not all attributes are provided (or using TypeScript typing to enforce correct usage) |
As per suggestion in steveukx/git-js#956 (comment)
As of version 3.21.0 (on npm now) you can get the initial commit hash with |
As per suggestion in steveukx/git-js#956 (comment)
I expected this to return list of commits between the first commit in the repository and the v1.0.0 tag:
In reality, it does not return any results.
That is because the above is translated into a git command like this:
(which might be interpreted by git as
Show me the commits that are in v1.0.0 but not in the current HEAD
- meaningless most of the time)to get the expected results (
Show me all the commits from the beginning of the repository's history up to the v1.0.0 tag.
), the command should look like this:Bug occurs on this line - https://github.com/steveukx/git-js/blob/main/simple-git/src/lib/tasks/log.ts#L126
Workaround
Until this is fixed, I use the following workaround to get expected results:
which looks harmlessly simple in this tiny example, but is quite ugly in my actual code:
in comparison, if this bug is fixed, the above would just look like this:
Version
Simple Git version: 3.20.0
Git version: 2.40.1
The text was updated successfully, but these errors were encountered: