Skip to content

Instantly share code, notes, and snippets.

View goyalmohit's full-sized avatar

mohit goyal goyalmohit

View GitHub Profile
@goyalmohit
goyalmohit / pre-rebase-2.sh
Last active April 14, 2019 13:20
Shell script for pre-rebase git hook to disable rebasing on different branch
#!/bin/sh
# disallows rebasing on different branch only
if [ ! -z $2 ]; then
echo "pre-rebase: Rebasing is dangerous, follow the golden rules of rebasing."
exit 1
else
echo "pre-rebase: Be careful of what you do"
fi
@goyalmohit
goyalmohit / pre-rebase.sh
Created April 14, 2019 13:15
Shell script for pre-rebase git hook
#!/bin/sh
# Disallow all rebasing
echo "pre-rebase: Rebasing is dangerous, follow the golden rules of rebasing."
exit 1
@goyalmohit
goyalmohit / post-checkout.py
Created April 14, 2019 13:09
Python script for post commit git hook to clear .retry files
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
# Collect the parameters
previous_head = sys.argv[1]
new_head = sys.argv[2]
is_branch_checkout = sys.argv[3]
if is_branch_checkout == "0":
@goyalmohit
goyalmohit / post-commit.py
Created April 14, 2019 11:46
Python script for git post-commit hook
#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
from subprocess import check_output
# Get the git log --stat entry of the new commit
log = check_output(['git', 'log', '-1', '--stat', 'HEAD'])
# Create a plaintext email message
msg = MIMEText("Look, I'm actually doing some work:\n\n%s" % log)
@goyalmohit
goyalmohit / commit-msg.py
Created April 14, 2019 11:39
Python script to control the git commit message as git hook
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
# Collect the parameters
commit_msg_filepath = sys.argv[1]
# Figure out which branch we're on
branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip()
print "commit-msg: On branch '%s'" % branch
@goyalmohit
goyalmohit / pre-commit-msg.py
Last active April 14, 2019 11:36
Python script for pre-commit message git hook
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
# Collect the parameters
commit_msg_filepath = sys.argv[1]
if len(sys.argv) > 2:
commit_type = sys.argv[2]
else:
commit_type = ''
if len(sys.argv) > 3:
@goyalmohit
goyalmohit / pre-commit.sample
Created April 14, 2019 09:49
Default pre-commit hook
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@goyalmohit
goyalmohit / rollback-database-using-liquibase
Created March 9, 2019 14:27
Rolling back database using liquibase
liquibase
--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
--classpath="C:\\Program Files\\Microsoft JDBC Driver 6.0 for SQL Server\\sqljdbc_6.0\\enu\\jre8\\sqljdbc42.jar"
--url="jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks2017;integratedSecurity=false;"
--changeLogFile="D:\Source\generateChangeLog.xml"
--username=liquibase
--password=liquibase@123
--logLevel=info
rollback rollbackToDate 2019-03-09 00:40:30.617
@goyalmohit
goyalmohit / create-table-and-populate-data-2
Created March 9, 2019 14:23
Create table and populate data along with rollback statements using liquibase
-- liquibase formatted sql
-- changeset mohitgoyal:20190309122800
CREATE TABLE [dbo].[CustomerDetails5](
[CustomerTypeID] [nchar](10) NULL,
[CustomerDesc] [nvarchar](max) NULL,
[CustomerAddress] [varchar](255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
--rollback DROP TABLE [dbo].[CustomerDetails5]
@goyalmohit
goyalmohit / create-and-populate-table-with-liquibase
Created March 9, 2019 13:57
Create and Populate Table using Liquibase
-- liquibase formatted sql
-- changeset mohitgoyal:20190309122800
CREATE TABLE [AdventureWorks2017].[dbo].[CustomerDetails5](
[CustomerTypeID] [nchar](10) NULL,
[CustomerDesc] [nvarchar](max) NULL,
[CustomerAddress] [varchar](255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
--rollback drop table CustomerDetails5