{"id":4430,"date":"2019-04-11T10:24:37","date_gmt":"2019-04-11T08:24:37","guid":{"rendered":"http:\/\/blog.via-internet.de\/?p=4430"},"modified":"2019-04-11T10:24:37","modified_gmt":"2019-04-11T08:24:37","slug":"using-git-in-multi-repository-environments","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2019\/04\/11\/using-git-in-multi-repository-environments\/","title":{"rendered":"SAS | Using Git and multi-repository environments"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Using Git Hooks<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ git config --global core.hooksPath .githooks<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Anhang: .githooks<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">prepare-commit-msg<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n#\n\nCOMMIT_MSG_FILE=$1\nCOMMIT_SOURCE=$2\nSHA1=$3\n\nbranchPath=$(git symbolic-ref -q HEAD)\nbranchName=${branchPath##*\/}\n\n\nif [ -n \"$branchName\" ]; then\n    echo \"$branchName | $(cat $1)\" > $1\nfi<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">pre-commit<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n#\n\n_BRANCHPATH=$(git symbolic-ref -q HEAD)\n_BRANCH=${_BRANCHPATH##*\/}\n\n_TIMESTAMP=\"$(date '+\n\nLOG() {\n        if [[ \"$GIT_COMMIT_DETAILED_LOGGING\" == \"YES\" ]]; then\n                echo \"LOG: $*\"\n        fi\n}\n\nREPLACE()\n{\n   local _TYP;   _TYP=\"$1\"; shift\n   local _TAG;   _TAG=\"$1\"; shift\n   local _WITH; _WITH=\"$1\"; shift\n   local _FILE; _FILE=\"$1\"; shift\n\n   case \"$_TYP\" in\n      SAS)       #  \n                 perl -pi -e 's\/(.*)(\n                ;;\n      CUSTOMER) # \/* __DEPLOY_TAG = \n                perl -pi -e 's\/(\\\/\\*\\s*)('\"__DEPLOY_$_TAG\"'\\s*=\\s*)(.*$)\/${1}${2}\n                ;;\n      *)        LOG \"Undefined typ '$TYP' for file $_FILE\"\n                ;;\n   esac\n\n   rm -f \"${_FILE}.bak\"\n}\n\nLOG \"working on branch $_BRANCH\"\n\nfor _FILE in $(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)\ndo\n        LOG \"checking file $_FILE\"\n\n        # Only examine known text files\n        if [[ \"$_FILE\" =~ [.](sas)$ ]]; then\n                LOG \"working on file $_FILE\"\n                REPLACE SAS TAG       \"$_BRANCH\"    \"$_FILE\"\n                REPLACE SAS TIMESTAMP \"$_TIMESTAMP\" \"$_FILE\"\n        fi\n\n        if [[ \"$_FILE\" =~ ^MA03 ]]; then\n                LOG \"working on bihis-customer script  $_FILE\"\n                REPLACE CUSTOMER TAG       \"$_BRANCH\"    \"$_FILE\"\n                REPLACE CUSTOMER TIMESTAMP \"$_TIMESTAMP\" \"$_FILE\"\n        fi\ndone<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using Git Hooks Anhang: .githooks prepare-commit-msg pre-commit<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[28,70],"tags":[],"class_list":["post-4430","post","type-post","status-publish","format-standard","hentry","category-git_github","category-sas"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/4430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=4430"}],"version-history":[{"count":0,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/4430\/revisions"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=4430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=4430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=4430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}