gabrielcsapo / gabrielcsapo/node-git-server

If the tag contains `00`, it will break there

Open
#113 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
262
Forks
81
PR merge metrics
No merged PRs in 30d

Description

I tried to push the following tag: `v72.94001.10`
However, the tag passed to the `tag` event was the following value:

```js
const { Git } = require('node-git-server');

const repos = new Git('path/to/tmp', {
autoCreate: true,
});

repos.on('tag', (tag) => {
// tag.version === 'v72.94' // What!?
});

repos.listen(49152, { type: 'http' }, () => {
// ...
});
repos.server.on('error', err => { throw err });
```

Apparently, tag names are cut off when `00` is encountered.
I have looked into the reason for this and found the following regular expression to be the cause.

https://github.com/gabrielcsapo/node-git-server/blob/2ab22a4d3f1a9c77314236c401e176f994f2f758/src/service.ts#L13

[This pattern is defined so that tag names after spaces, null characters, or `00` are not retrieved](https://regexper.com/#%28%5B0-9a-fA-F%5D%2B%29%20%28%5B0-9a-fA-F%5D%2B%29%20refs%5C%2F%28heads%7Ctags%29%5C%2F%28.*%3F%29%28%20%7C00%7C%5Cu0000%29%7C%5E%280000%29%24).
_Why?_ Tag names (and branch names) can contain `00`. What is the reason for excluding anything after `00`?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the v72.94001.10 tag from the report, then inspect the regular expression at src/service.ts line 13 and the surrounding tag-event parsing. Confirm that tag and branch names containing 00 are preserved, while the existing ref parsing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.