-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Add git version #28
base: master
Are you sure you want to change the base?
Conversation
Closes: #26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ImpulseDeer! Thank you for the PR. Generally looks great. I only have two concerns:
- Exporting a new macro doesn't seem like the best idea. It would be better to add this to the existing macro, especially when there is some duplication of returned data.
- Adding a new
execSync
call will have performance implications. I remember reducing the number of calls we make to git to 1 to speed up compilation. I would have to check but would it be possible to get this information directly from a single call togit-log
?
/** | ||
* Abbreviated commit hash. | ||
*/ | ||
readonly shortHash: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this duplicated from the original macro?
@@ -1,2 +1,2 @@ | |||
// Inspired by https://github.com/kentcdodds/babel-plugin-preval/blob/master/macro.js | |||
module.exports = require('./src/GitInfo.macro') | |||
module.exports = require('./src/GitVersion.macro') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... the export of two macros would be somewhat complicated. I would suggest having it be part of the same macro.
}); | ||
}; | ||
|
||
module.exports = createMacro(getGitVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name GitVersion
doesn't seem too accurate for what it does.
@@ -4,7 +4,7 @@ const gitInfo = GitInfo(); | |||
|
|||
describe('Git information', () => { | |||
test('gets correct branch', () => { | |||
expect(gitInfo.branch).toBe('master'); | |||
expect(gitInfo.branch).toBe('main'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did upstream Git change the default branch name already?
Tried adding a git version macro using
git describe --tags --long --dirty
Based on a fork by martatesar: master...martatesar:react-git-info:master
I envisioned GitInfo and GitVersion as two different macros in the same way as they are different git commands.
But haven't figured out if that is doable or not with babel-plugin-macros yet.
Current state of the branch is that I have inactivated the original GitInfo macro to test the new GitVersion macro.
Help and feedback is welcome on how to proceed.