Skip to content

Push parsing sometimes truncates commit messages and rejects them as empty #971

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

Open
kriswest opened this issue Apr 10, 2025 · 0 comments · May be fixed by #976
Open

Push parsing sometimes truncates commit messages and rejects them as empty #971

kriswest opened this issue Apr 10, 2025 · 0 comments · May be fixed by #976

Comments

@kriswest
Copy link
Contributor

Describe the bug
We have a PR to raise (git-proxy) that gets rejected due to an empty commit message. However the commit message is NOT empty, it just doesn't end in a new line...

Log excerpt for a healthy commit:

{
  x: {
    item: 15,
    value: 158,
    type: 1,
    size: 254,
    deflatedSize: 175,
    objectRef: null,
    content: 'tree e9eb708d213e4d972a802aa5294f7c3e7dfb3ade\n' +
      'parent 62bb851d12b4d00fb48e50f917a9b1608b1beefc\n' +
      'author Kris West <[email protected]> 1741783837 +0000\n' +
      'committer Kris West <[email protected]> 1742841749 +0000\n' +
      '\n' +
      'fix: clean up ldaphelper.js\n'
  }
}
{
  formattedContent: [
    'tree e9eb708d213e4d972a802aa5294f7c3e7dfb3ade',
    'parent 62bb851d12b4d00fb48e50f917a9b1608b1beefc',
    'author Kris West <[email protected]> 1741783837 +0000',
    'committer Kris West <[email protected]> 1742841749 +0000',
    '',
    'fix: clean up ldaphelper.js',
    ''
  ]
}
{
  parts: [
    'tree e9eb708d213e4d972a802aa5294f7c3e7dfb3ade',
    'parent 62bb851d12b4d00fb48e50f917a9b1608b1beefc',
    'author Kris West <[email protected]> 1741783837 +0000',
    'committer Kris West <[email protected]> 1742841749 +0000',
    'fix: clean up ldaphelper.js'
  ]
}
{ tree: 'e9eb708d213e4d972a802aa5294f7c3e7dfb3ade' }
{ parentValue: 'parent 62bb851d12b4d00fb48e50f917a9b1608b1beefc' }
{ parent: '62bb851d12b4d00fb48e50f917a9b1608b1beefc' }
{ author: 'Kris West <[email protected]> 1741783837 +0000' }
{
  committer: 'Kris West <[email protected]> 1742841749 +0000'
}
{ indexOfMessages: 4 }
{ message: 'fix: clean up ldaphelper.js' }

Log excerpt for a commit that fails:

{
  x: {
    item: 16,
    value: 145,
    type: 1,
    size: 289,
    deflatedSize: 223,
    objectRef: null,
    content: 'tree b62594e4beac34d85f72b7f3daefc42c0401b8de\n' +
      'parent 08cd0ed34616c5d05a92062a009eda289ca4576f\n' +
      'author Hemant Sharma <[email protected]> 1741703647 +0000\n' +
      'committer Kris West <[email protected]> 1742841749 +0000\n' +
      '\n' +
      'Edit activeDirectory.js for GitProxy Non Prod Implementation'
  }
}
{
  formattedContent: [
    'tree b62594e4beac34d85f72b7f3daefc42c0401b8de',
    'parent 08cd0ed34616c5d05a92062a009eda289ca4576f',
    'author Hemant Sharma <[email protected]> 1741703647 +0000',
    'committer Kris West <[email protected]> 1742841749 +0000',
    '',
    'Edit activeDirectory.js for GitProxy Non Prod Implementation'
  ]
}
{
  parts: [
    'tree b62594e4beac34d85f72b7f3daefc42c0401b8de',
    'parent 08cd0ed34616c5d05a92062a009eda289ca4576f',
    'author Hemant Sharma <[email protected]> 1741703647 +0000',
    'committer Kris West <[email protected]> 1742841749 +0000',
    'Edit activeDirectory.js for GitProxy Non Prod Implementation'
  ]
}
{ tree: 'b62594e4beac34d85f72b7f3daefc42c0401b8de' }
{ parentValue: 'parent 08cd0ed34616c5d05a92062a009eda289ca4576f' }
{ parent: '08cd0ed34616c5d05a92062a009eda289ca4576f' }
{
  author: 'Hemant Sharma <[email protected]> 1741703647 +0000'
}
{
  committer: 'Kris West <[email protected]> 1742841749 +0000'
}
{ indexOfMessages: 4 }
{ message: '' }

Note how the commitMessage does not end in a newline, where it does in the healthy commit(s). This causes formattedContent to be one element shorter.

I believe the message is then not retrieved due to this slice:

const message = formattedContent
.slice(indexOfMessages + 1, formattedContent.length - 1)
.join(' ');

whose end is calculated based on the length of formatedContent. By changing it to:

const message = formattedContent 
   .slice(indexOfMessages + 1) 
   .join(' ').trim(); 

this can be avoided.

Expected behavior
Commits that have messages should be parsed as having messages, even if they don't end in a newline

Additional context
I'll raise a PR to resolve this issue

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 a pull request may close this issue.

1 participant