Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _table="system_branch_overview"
- _deleteQuery="Delete from "$_table
- mysql --user="dashboard" --password="dashboard" --host="data.cgn" "cc-statistics" --protocol=TCP -e "$_deleteQuery"
- #------------navigate----------------------
- for d in ./*/
- do
- cd "$d"
- _gitDir="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
- if [ "$_gitDir" == "true" ]
- then
- _system="${d:2}"
- _system="${_system::-1}"
- #-------------branch------------------------
- git branch > tmp_checked_branch.file
- _file='tmp_checked_branch.file'
- _re="*"
- while IFS='' read -r p || [ -n "$p" ]; do
- if [ "${p:0:1}" == "$_re" ]
- then
- _checked_branch="${p:2}"
- fi
- done < "$_file"
- rm "$_file"
- #-------------commit hash--------------------
- git show -s > tmp_checked_commit.file
- _file='tmp_checked_commit.file'
- _commitHash=$(head -1 "$_file")
- _commitHash="${_commitHash:7}"
- #-------------commit date $ message----------
- headtail2=$(head -2 "$_file" | tail +2)
- if [[ "$_headtail2" =~ "Merge"* ]]
- then
- _commitDate=$(head -4 "$_file" | tail +4)
- _commitMessage=$(cat "$_file" | tail +6)
- elif [[ "_$headtail2" =~ "Author"* ]]
- then
- _commitDate=$(head -3 "$_file" | tail +3)
- _commitMessage=$(cat "$_file" | tail +5)
- fi
- #remove "Date: "
- _commitDate="${_commitDate:8}"
- #format date for sql insert
- _commitDate="${_commitDate:4:20}"
- _cDate="${_commitDate: -1}"
- echo "$_cDate"
- if [[ !"$_cDate" =~ [0-9]+$ ]]
- then
- _commitDate="${_commitDate:19}"
- fi
- #echo "$_commitDate"
- #remove 4 leading whitespaces
- _commitMessage="${_commitMessage:4}"
- rm "$_file"
- #----------------sql insert-------------------
- _table="system_branch_overview"
- _toDate="STR_TO_DATE('$_commitDate','%M %d %h:%i:%s %Y')"
- _insertQuery="INSERT INTO "$_table" VALUES ('"$_commitHash"','"$_system"','"$_checked_branch"','"$_commitMessage"',"$_toDate")"
- echo "$_insertQuery"
- mysql --user="dashboard" --password="dashboard" --host="data.cgn" "cc-statistics" --protocol=TCP -e "$_insertQuery"
- fi
- cd ..
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement