Skip to content

Remove trailing newline characters from git branch#7

Merged
lowitea merged 2 commits intolowitea:masterfrom
robin-moser:master
Jul 28, 2025
Merged

Remove trailing newline characters from git branch#7
lowitea merged 2 commits intolowitea:masterfrom
robin-moser:master

Conversation

@robin-moser
Copy link
Copy Markdown
Contributor

@robin-moser robin-moser commented Jul 25, 2025

On MacOS, the parsing of the git branch results in an added newline character:

 - 2025-07-25 12:50:36 (0:00:02) {'branch': 'main\n', 'file': 'README.md', 'language': 'markdown', 'project': 'nvim'}

This PR removes these characters, if they are present. I don't know if this is a MacOS specific bug, or even only local to my machine, but i think it wouldn't hurt to add this check to all systems. What dou you think?

EDIT:
Also, if I'm not in a git repository, the git error gets written in the branch field:

- 2025-07-25 13:12:40 (0:00:12) {'branch': 'fatal: not a git repository (or any of the parent directories): .git', 'file': 'test.sh', 'language': 'sh', 'project': 'test'}

I added a commit to supress stderr.

Thanks for the plugin!

@lowitea
Copy link
Copy Markdown
Owner

lowitea commented Jul 28, 2025

Hi, thanks for the pr.
Yes, it looks more robust.

@lowitea lowitea merged commit c9cdc22 into lowitea:master Jul 28, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants