-
Notifications
You must be signed in to change notification settings - Fork 386
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
FR: be able to set commit_timestamp contextually #5366
Comments
This is a limitation of the current template engine, which can't express generics internally. If we rewrite the engine in a way that template values are dynamically typed, maybe we can change For now, we'll probably need |
'commit_timestamp(commit)' = '''
if(commit.current_working_copy() || commit.hidden(),
commit.committer().timestamp(),
commit.author().timestamp()
)
''' However, maybe we should have something like a latent 'commit_timestamp(commit)' = '''
if(context.command() == "evolog",
commit.committer().timestamp(),
commit.author().timestamp()
)
''' |
For this use case, #5311 will help. |
Yep! I did exactly that initially (and what Yuya said). I was trying another hack and pasted that in the OP by mistake (I'll leave it as is now). So the hack is to use commit_timestamp like (yet to exist) format_commit_timestamp and set format_timestamp to identity function: 'format_timestamp(timestamp)' = 'timestamp' (of course, "timestamp" is a template here, not a timestamp). |
Btw, I think this can be implemented in the same way that we handle comparison operators, but we can't make In |
Yuya, I wonder if some sort of type assertions are easier to implement? |
No. It would require rewrites. Templater internals are strictly typed. It's difficult to deal with dynamically-specified type names. |
I prefer author timestamp to committer timestamp in general but found it to be somewhat useless for evolog and working copy (it'll probably be confusing at times to have working copy use committer timestamp and all other commits use author timestamp but I want to try).
Given evolog mostly has hidden commits, I tried something like:
.. which doesn't work because I'm setting commit_timestamp to a template, not to a timestamp.
This example is perhaps not the strongest case for it, but it would be nice for templates to able to resolve / assert to specific types. That aside, I'm curious if there's any other way to do what I want (other than changing code to provide more hooks, I guess).
The text was updated successfully, but these errors were encountered: