You are here

Useful one-liner for building template git comment

Ivan Radovanovic's picture

Goes like this:
git status | grep modified: | awk 'BEGIN {FS="[ \t]+modified:[ \t]+";print "Change summary\n";} {print "* " $2 "\t\n";}'

Sample output:

Change summary

* include/Application.hpp

* include/fengine.hpp

* nginx.sh

* samples/if.ftx

* src/fEngine/compiling/Compiler.cpp

* src/fEngine/compiling/Compiling.cpp

* src/fEngine/f/Alt.cpp

* src/fEngine/f/BuiltInTag.cpp

* src/fEngine/f/Case.cpp

* src/fEngine/f/CodeGenerator.cpp

* src/fEngine/f/Default.cpp

* src/fEngine/f/ElIf.cpp

* src/fEngine/f/Else.cpp

* src/fEngine/f/Footer.cpp

* src/fEngine/f/Foreach.cpp

* src/fEngine/f/Header.cpp

* src/fEngine/f/If.cpp

* src/fEngine/f/Item.cpp

* src/fEngine/f/Link.cpp

* src/fEngine/f/List.cpp

* src/fEngine/f/Placeholder.cpp

* src/fEngine/f/Row.cpp

* src/fEngine/f/Separator.cpp

* src/fEngine/f/Switch.cpp

* src/fEngine/f/Table.cpp

* src/fEngine/f/When.cpp

* src/fEngine/http/HttpRequest.cpp

* src/fEngine/http/HttpResponse.cpp

* src/fEngine/parser/Print.cpp

* src/fEngine/parser/TemplateDeclaration.cpp

* src/fEngine/parser/TemplateDeclaration.hpp

* src/fEngine/pch.hpp

* src/fEngine/settings/ConfigFile.cpp

* src/fEngine/settings/ConfigSettings.cpp

* src/fEngine/templates/Application.cpp

* src/fEngine/templates/CustomTag.cpp

* src/fEngine/templates/Lambda.cpp

* src/fEngine/templates/Template.cpp

Tags: 

Comments

Ivan Radovanovic's picture


git status | \
grep modified: | \
awk 'BEGIN {FS="[ \t]+modified:[ \t]+"} {split($2, path, "/"); rev_str = ""; path_len = length(path); for (i = 0; i < path_len; i++) rev_str = rev_str path[path_len - i]; files[rev_str] = $2; } END {for (f in files) print f "\t" files[f];}' | \
sort -f | \
awk 'BEGIN { FS="\t+"; print "Change Summary\n"; } {print "* " $2 "\n";}'

Output similar to:

Change Summary

* src/fEngine/f/Alt.cpp

* include/f/Alt.hpp

* src/fEngine/templates/Application.cpp

* src/fEngine/f/Case.cpp

* include/f/Case.hpp

* src/fEngine/compiling/Compiling.cpp

* include/Compiling.hpp

* src/fEngine/templates/CustomTag.cpp

* include/CustomTag.hpp

* src/fEngine/f/Default.cpp

* include/f/Default.hpp

working in AraxaTech

Ivan Radovanovic's picture

Since previous versions did not capture other modification statuses (renamed, new etc.).

git status | \
grep -E "(modified|new file|copied|renamed):" | \
awk 'BEGIN {FS="[ \t]+(modified|new file|copied|renamed):[ \t]+"} {split($2, path, "/"); rev_str = ""; path_len = length(path); for (i = 0; i < path_len; i++) rev_str = rev_str path[path_len - i]; files[rev_str] = $2; } END {for (f in files) print f "\t" files[f];}' | \
sort -f | \
awk 'BEGIN { FS="\t+"; print "Change Summary\n"; } {print "* " $2 "\n";}'

working in AraxaTech