[WIP] Add git version#28
Open
ImpulseDeer wants to merge 2 commits intoAbhyudayaSharma:masterfrom
Open
Conversation
Author
|
Closes: #26 |
AbhyudayaSharma
requested changes
Oct 16, 2022
Owner
AbhyudayaSharma
left a comment
There was a problem hiding this comment.
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
execSynccall 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; |
Owner
There was a problem hiding this comment.
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') | |||
Owner
There was a problem hiding this comment.
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); |
Owner
There was a problem hiding this comment.
I think the name GitVersion doesn't seem too accurate for what it does.
| describe('Git information', () => { | ||
| test('gets correct branch', () => { | ||
| expect(gitInfo.branch).toBe('master'); | ||
| expect(gitInfo.branch).toBe('main'); |
Owner
There was a problem hiding this comment.
Did upstream Git change the default branch name already?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tried adding a git version macro using
git describe --tags --long --dirtyBased 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.