{"id":292,"date":"2012-09-19T18:30:34","date_gmt":"2012-09-19T22:30:34","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/acts\/?p=292"},"modified":"2012-09-19T23:05:18","modified_gmt":"2012-09-20T03:05:18","slug":"checking-your-syntax-on-commit","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/acts\/2012\/09\/19\/checking-your-syntax-on-commit\/","title":{"rendered":"Checking your syntax on commit"},"content":{"rendered":"<p>A good IDE can spot programming syntax errors and alert you to them before they ever make it into a git commit. However, sometimes when you&#8217;re in a hurry, tired, or distracted, these alerts go unnoticed and there is a greater risk that you&#8217;ll commit broken files to your git branch. <a href=\"http:\/\/stackoverflow.com\/a\/4114122\" title=\"git makes it a snap to fix this\">Git makes it a snap to revert changes<\/a>, but wouldn&#8217;t it be nicer if you could prevent it from happening in the first place?<\/p>\n<p>To that end, git has a nice feature called <a href=\"http:\/\/git-scm.com\/book\/en\/Customizing-Git-Git-Hooks\" title=\"hooks\">client-side hooks<\/a>. In particular, you can create a hook known as a <em>pre-commit<\/em> hook that executes right before you commit something. It gives you the option to abort if something doesn&#8217;t look right. Using this feature, I created a simple <a href=\"http:\/\/pastebin.com\/Z1xWyZu4\" title=\"sample script\">script to check PHP and Javascript syntax on commit<\/a>. It&#8217;s helpful for those mornings when I haven&#8217;t quite had enough coffee yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A good IDE can spot programming syntax errors and alert you to them before they ever make it into a git commit. However, sometimes when you&#8217;re in a hurry, tired, or distracted, these alerts go unnoticed and there is a greater risk that you&#8217;ll commit broken files to your git branch. Git makes it a [&hellip;]<\/p>\n","protected":false},"author":4572,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3772,17295,3163,1,63993],"tags":[],"class_list":["post-292","post","type-post","status-publish","format-standard","hentry","category-git","category-javascript","category-php","category-uncategorized","category-version-control"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/users\/4572"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":19,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/292\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/media?parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/categories?post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/tags?post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}