Skip to content
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

Add $Author$ and $Date$ convertions to git commit #1

Open
TheSin- opened this issue Sep 27, 2016 · 1 comment
Open

Add $Author$ and $Date$ convertions to git commit #1

TheSin- opened this issue Sep 27, 2016 · 1 comment

Comments

@TheSin-
Copy link
Member

TheSin- commented Sep 27, 2016

eed to add $Author$ and $Date$ convertions to git commit.

see https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion for examples

@TheSin-
Copy link
Member Author

TheSin- commented Oct 11, 2016

looks like the link provided is client side which means all users need to remember to set it up, which isn't ideal.

I also explored git hooks, .git/hook/update specifically since it runs server side. But to enable this you need to get the file on the server git repo and GitHub doesn't provide shell access.

The only idea I have currently is on the web server side, when I update the website I could process the list of updated files and use

for i in <updated files *.php>; do
author=`git log -1 --pretty=format:'%an' $i;
date=`git log -1 --pretty=format:'%ai' $i;
sed -i -e 's/\$Author\$/$Author: ${author} $/g $i;
sed -i -e 's/\$Date\$/$Date: ${date} $/g $i;
done

to get the author and date and injected it by hand at that point. Only down side is that we should a reset the git to only show $Date$ and $Author$ since it'll never update in the repo. And there would be a slight race condition, since to update a modified file I'd have to do a hard reset on the repo then update then loop and fix, during that time page loads would display 'Date' and 'Author' literally. Though with GitHub this might be the only and best option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant