This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
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.
Re-introduce commit message template #1756
Re-introduce commit message template #1756
Changes from 27 commits
f5ccd16
0a24012
49a1d31
3ebda2f
b6ef6d2
d895691
bcbbff8
b8e55ab
ca10d13
99fe542
40b015e
ade7de8
7c18ddb
7a73138
b16525c
b3cc2c3
5a7b2d4
b3588ef
4a1525b
2c2857e
f780ad1
5ee83db
6e45f0c
56d9f5e
d145084
8a40a74
63ffa69
c15f1d0
fd1d1cf
3d94405
acf502c
9b606ba
6379f30
d331372
13e7342
218f193
e2cc423
b3c9ec7
37fbb44
6299ae2
8aaf2ac
e8e39db
3e1cb40
a87b3a4
6f88f76
4e400bd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is there a reason this is constructed with
new RegExp()
rather than as a regexp literal? Is it just for readability so you don't have to escape all of the/
and get into leaning-toothpick-syndrome?A more descriptive name than
regex
may be nice too 😄 How about something liketildeExpansionPattern
?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.
We didn't really have a strong reason for preferring the regexp constructor over literals here. We went with what the original author had.
Out of curiosity, we looked to see if there was a performance difference. Answer: not really.
https://www.measurethat.net/Benchmarks/Show/1734/1/regexp-constructor-vs-literal
We did give it a more descriptive name, and moved it out of this function so as to avoid creating a new regex every time.
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.
@smashwilson: can you test this on non-Mac operating systems? We want to make sure if a username is specified, it does the right thing for our Linux and or Windows users.
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.
Can do, and will report back 🙇
One thing that I can see right away is that this won't handle
~root/
correctly; on most *nix systems, that should expand to/root
, not/users/root
. In general the right thing to do on Unix-y systems is to usegetpwnam(3)
to read the definitive information, taking into account any weird local network drive setups and so on. Windows I'm less familiar with.There are a few tilde-expansion libraries on npm, but unfortunately looking at their source it doesn't look like many of them handle all of this correctly either! I found one that uses etc-passwd to read its info, but I don't believe it has any accommodations for Windows. This may be a sign that this isn't important enough to hold up the 🚢 for 😉
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 wonder if the commit message, commit message template, and merge message tracking belong more naturally in
Repository
rather thanPresent
. Most methods inPresent
are intended to call a single git command withGitShellOutStrategy
, manipulate the cache, and translate input and output to our model objects, whileRepository
methods implement higher-order composite behavior. Commit message derivation feels like a "composite" behavior to me 🤔With that said: we already have a bunch of behavior in
Repository
andPresent
that blurs these lines, and it would not be trivial to move all of this there. So maybe we could leave this as a future refactoring as part of a broader effort to make the division among those abstraction layers clear.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.
cool - should I open an issue to refactor this in the future? I'm on board with cleaning it up.
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.
It's odd to me that
getCommitMessageTemplate()
is a git operation, butsetCommitMessageTemplate()
is an accessor for an instance variable. Can we clarify the names to be less misleading somehow?Also: should the result of this git operation be cached?
Fake edit: on reflection, caching this would cause some weird behavior because we don't have a filesystem watcher on the commit message template itself, so we wouldn't know when to invalidate that cache entry.
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.
hahaha yup Katrina and I went through that exact conversation re caching.
renamed the method to
fetchCommitMessageTemplate
. I'm not 100% sure that's better, but perhaps folks won't think it's the inverse operation ofsetCommitMessageTemplate
?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.
Might be worth extracting this to
helpers.js
?It is a one-liner, but eh.
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.
sure! Good suggestion. Extracted.