{"thread":{"id":"56328","subject":"General questions - git archive a .j2 file with keyword expansion in the header section","startedAt":"2021-08-19T21:28:16Z","lastAt":"2021-08-19T22:28:04Z","messageCount":2,"participants":["Lin, Nathan (GSE)","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433173","messageId":"DF4PR8401MB0795EE7D2828A45289295D3892C09@DF4PR8401MB0795.NAMPRD84.PROD.OUTLOOK.COM","threadId":"56328","inReplyTo":null,"subject":"General questions - git archive a .j2 file with keyword expansion in the header section","fromName":"Lin, Nathan (GSE)","fromEmail":"jih-tsen.nat.lin@hpe.com","sentAt":"2021-08-19T21:28:11Z","receivedAt":"2021-08-19T21:28:16Z","isPatch":false,"sender":{"key":"jih-tsen.nat.lin@hpe.com","avatar":null},"body":"Hello Devs,\n\nGot a question on using git keyword expansion on a .j2 template file. Keyword expansion does not seem to work with .j2 file. Please see below a snippet of my attempt to archive test.cfg.j2 containing git keyword expansions in the header. It works if I changes the .j2 file extension to something else, say .yaml. I have not been able to find any information about issue. Can you please review and advise? Thank you.\n\n\n[root@da ~]# cat Ansible_Playbooks/Day0/roles/hpe-bm-kickstart/templates/test.cfg.j2 \n##############################################################################\n# Author : $Format: %an <%ae>$\n# Commit : $Format: %h$\n# Date   : $Format: %cs$\n#\n##############################################################################\n\n[root@da ~]# git archive --format=tgz HEAD --output=test.tar.gz Ansible_Playbooks/Day0/roles/hpe-bm-kickstart/templates/test.cfg.j2\n[root@da ~]# tar -xf test.tar.gz  --directory test\n[root@da ~]# cat test\ntest/        test.tar.gz  \n[root@da ~]# cat test\ntest/        test.tar.gz  \n[root@da ~]# cat test/Ansible_Playbooks/Day0/roles/hpe-bm-kickstart/templates/test.cfg.j2 \n##############################################################################\n# Author : $Format: %an <%ae>$\n# Commit : $Format: %h$\n# Date   : $Format: %cs$\n#\n##############################################################################\n\n[root@da ~]#\n\n\n\nRegards,\nNathan Lin\nSolutions Engineer\nGlobal Sales Engineering (GSE)\nhttps://hpe.com/info/askgse (Internal site)\n+1 (281) 204-4077 Office\n\nHouston, TX\nhpe.com\n\n"},{"id":"433175","messageId":"YR7a8vKrYgFJof0D@coredump.intra.peff.net","threadId":"56328","inReplyTo":"DF4PR8401MB0795EE7D2828A45289295D3892C09@DF4PR8401MB0795.NAMPRD84.PROD.OUTLOOK.COM","subject":"Re: General questions - git archive a .j2 file with keyword expansion in the header section","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-08-19T22:28:02Z","receivedAt":"2021-08-19T22:28:04Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 19, 2021 at 09:28:11PM +0000, Lin, Nathan (GSE) wrote:\n\n> Got a question on using git keyword expansion on a .j2 template file.\n> Keyword expansion does not seem to work with .j2 file. Please see\n> below a snippet of my attempt to archive test.cfg.j2 containing git\n> keyword expansions in the header. It works if I changes the .j2 file\n> extension to something else, say .yaml. I have not been able to find\n> any information about issue. Can you please review and advise? Thank\n> you.\n\nDo you have .gitattributes entries that tell Git it should apply the\n\"export-subst\" attribute to any files? If so, does it cover .yaml files,\nbut not .j2?\n\n-Peff\n"}]}