Skip to content

Instantly share code, notes, and snippets.

@IamADav
Created February 1, 2025 14:40
Show Gist options
  • Select an option

  • Save IamADav/2fcf0522d53e6d5074e71a90b5dc433d to your computer and use it in GitHub Desktop.

Select an option

Save IamADav/2fcf0522d53e6d5074e71a90b5dc433d to your computer and use it in GitHub Desktop.
Generate a class that can be used as a stamp.
file=$1
url=`git config --get remote.origin.url`
branch=`git rev-parse --abbrev-ref HEAD`
gitedate=`git show -s --format=%ci`
sha=`git show -s --format=%H`
echo $gitedate
printf "namespace $2\r"> $file
printf "{\r ">> $file
printf " public class InfoVersion\r ">> $file
printf " {\r ">> $file
printf " public string Repo { get; set; }\r ">> $file
printf " public string Branch { get; set; }\r ">> $file
printf " public string Date { get; set; }\r ">> $file
printf " public string Sha { get; set; }\r ">> $file
printf " public string ComputerName { get; set; }\r ">> $file
printf " public string CompileDate { get; set; }\r ">> $file
printf "\r ">> $file
printf " public InfoVersion()\r ">> $file
printf " {\r ">> $file
printf " Repo = \"$url\";\r ">> $file
printf " Branch = \"$branch\";\r ">> $file
printf " Date = \"$gitedate\";\r ">> $file
printf " Sha = \"$sha\";\r ">> $file
printf " ComputerName = \"Gitlab\";\r ">> $file
printf " CompileDate = \"$(date)\";\r ">> $file
printf " }\r ">> $file
printf " }\r ">> $file
printf "}\r" >> $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment