{"id":243,"date":"2018-09-13T17:45:40","date_gmt":"2018-09-13T21:45:40","guid":{"rendered":"https:\/\/www.ectropyarts.com\/?p=243"},"modified":"2023-01-11T11:48:11","modified_gmt":"2023-01-11T16:48:11","slug":"manually-trigger-a-post-receive-hook-for-testing","status":"publish","type":"post","link":"https:\/\/www.ectropyarts.com\/manually-trigger-a-post-receive-hook-for-testing\/","title":{"rendered":"Manually trigger a git post-receive hook for testing"},"content":{"rendered":"

Using a post-receive hook is a good way to perform a scripted action each time new changes are pushed to a git repo. (If you have not yet set up a basic post-receive hook, consider consulting this article<\/a>.)<\/p>\n

If you’re interested in adding more to your post-receive hook, you might want to have a quick way to test it, without adding & pushing a bunch of test commits. We can trigger it manually with this advice from Kris Jordan.<\/a><\/p>\n

\n

When you’re working on a post-receive hook, it’s annoying to muck up your project’s commit history and push each time you make a change. Luckily, because it’s just a script, we can fake it from the command-line.<\/p>\n

cd ..\/remote\r\ngit log -2 --format=oneline --reverse\r\n<\/pre>\n

First, we need to get the IDs of our most recent 2 commits. The git log command, above, will give us these two IDs in the order you’ll want to replace the $FROM_ID and $TO_ID variables with, respectively.<\/p>\n

echo \"$FROM_ID $TO_ID refs\/heads\/master\" | .\/hooks\/post-receive<\/pre>\n

This method makes setting up your post-receive hooks enjoyable, enabling you to quickly iterate on your script and execute it repeatedly.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

Using a post-receive hook is a good way to perform a scripted action each time new changes are pushed to a git repo. (If you have not yet set up a basic post-receive hook, consider consulting this article.) If you’re interested in adding more to your post-receive hook, you might want to have a quick […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[5,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/243"}],"collection":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":6,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":1330,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/243\/revisions\/1330"}],"wp:attachment":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}