From e394b2ec9992bc5f36c7c9a965ee44a16d3f8634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Tue, 10 Feb 2015 10:19:51 +0200 Subject: [PATCH 01/11] Added the script that will init the git hooks --- scripts/init-git-post-commit | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/init-git-post-commit diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit new file mode 100644 index 0000000..7b57566 --- /dev/null +++ b/scripts/init-git-post-commit @@ -0,0 +1,11 @@ +#!/bin/sh + +git config --global init.templatedir '~/.git-templates' +mkdir -p ~/.git-templates/hooks + +cat << EOF > ~/.bat/logo.svg +#!/bin/sh + +# Copy last commit hash to clipboard on commit +echo 'POST COMMIT' +EOF From 26378a59282b2a4770a5f1c93ac8c00ecce2ff36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Tue, 10 Feb 2015 10:39:40 +0200 Subject: [PATCH 02/11] Added the code that will be written in post-commit file --- scripts/init-git-post-commit | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit index 7b57566..33f8d90 100644 --- a/scripts/init-git-post-commit +++ b/scripts/init-git-post-commit @@ -7,5 +7,9 @@ cat << EOF > ~/.bat/logo.svg #!/bin/sh # Copy last commit hash to clipboard on commit -echo 'POST COMMIT' +commit_hash=`git rev-parse HEAD` +repo_url=`git config --get remote.origin.url` +commit_date=`git log -1 --format=%cd` +commit_data="\"{ \"date\": \"$commit_date\", \"url\": \"$repo_url\", \"hash\": \"$commit_hash\" }\"" +git-stats --record "$commit_data" EOF From 445776da3f3ca58618623de6606a0f71d688ed7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Tue, 10 Feb 2015 10:49:17 +0200 Subject: [PATCH 03/11] Made the script executable. --- scripts/init-git-post-commit | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/init-git-post-commit diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit old mode 100644 new mode 100755 From f4fe5cae94bbb13eed1577172afd7fc1e4f80105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 19:19:22 +0200 Subject: [PATCH 04/11] Fixed the post commit path. --- scripts/init-git-post-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit index 33f8d90..5b8941d 100755 --- a/scripts/init-git-post-commit +++ b/scripts/init-git-post-commit @@ -3,7 +3,7 @@ git config --global init.templatedir '~/.git-templates' mkdir -p ~/.git-templates/hooks -cat << EOF > ~/.bat/logo.svg +cat << EOF > ~/.git-templates/hooks/post-commit #!/bin/sh # Copy last commit hash to clipboard on commit From 8bfa382d3caff75b31a350b0c98660271b321d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 19:25:44 +0200 Subject: [PATCH 05/11] Make the file executable --- scripts/init-git-post-commit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit index 5b8941d..e17a630 100755 --- a/scripts/init-git-post-commit +++ b/scripts/init-git-post-commit @@ -2,8 +2,9 @@ git config --global init.templatedir '~/.git-templates' mkdir -p ~/.git-templates/hooks +post_commit_path="~/.git-templates/hooks/post-commit" -cat << EOF > ~/.git-templates/hooks/post-commit +cat << EOF > $post_commit_path #!/bin/sh # Copy last commit hash to clipboard on commit @@ -13,3 +14,5 @@ commit_date=`git log -1 --format=%cd` commit_data="\"{ \"date\": \"$commit_date\", \"url\": \"$repo_url\", \"hash\": \"$commit_hash\" }\"" git-stats --record "$commit_data" EOF + +chmod +x $post_commit_path From 4fd290d43f74e5742ef62709cfe1da66c588c4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 19:33:45 +0200 Subject: [PATCH 06/11] Use variables and escape the eof content. --- scripts/init-git-post-commit | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/init-git-post-commit b/scripts/init-git-post-commit index e17a630..88a0875 100755 --- a/scripts/init-git-post-commit +++ b/scripts/init-git-post-commit @@ -1,18 +1,21 @@ #!/bin/sh -git config --global init.templatedir '~/.git-templates' -mkdir -p ~/.git-templates/hooks -post_commit_path="~/.git-templates/hooks/post-commit" +git_templates_dir="$HOME/.git-templates" +git_hooks_dir="$git_templates_dir/hooks" +post_commit_path="$git_hooks_dir/post-commit" + +git config --global init.templatedir $git_templates_dir +mkdir -p $git_hooks_dir cat << EOF > $post_commit_path #!/bin/sh # Copy last commit hash to clipboard on commit -commit_hash=`git rev-parse HEAD` -repo_url=`git config --get remote.origin.url` -commit_date=`git log -1 --format=%cd` -commit_data="\"{ \"date\": \"$commit_date\", \"url\": \"$repo_url\", \"hash\": \"$commit_hash\" }\"" -git-stats --record "$commit_data" +commit_hash=\`git rev-parse HEAD\` +repo_url=\`git config --get remote.origin.url\` +commit_date=\`git log -1 --format=%cd\` +commit_data="\"{ \"date\": \"\$commit_date\", \"url\": \"\$repo_url\", \"hash\": \"\$commit_hash\" }\"" +git-stats --record "\$commit_data" EOF chmod +x $post_commit_path From 669e4d9581de0e455d94b52d13f1dd4276e697c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 20:07:10 +0200 Subject: [PATCH 07/11] Updated docs --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index bf9b84f..62f6577 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,23 @@ $ npm install -g git-stats ### Catching the `git commit` command Would you like to catch and automatically store the commits when you do `git commit`? +#### Using `git` hooks +The way I recommend to track your git commits is to use git hooks. Run the following command to initialize the `post-commit` git hook. + +```sh +# Using curl +curl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/git-hooks/scripts/init-git-post-commit | bash + +# ...or wget +wget -qO- https://raw.githubusercontent.com/IonicaBizau/git-stats/git-hooks/scripts/init-git-post-commit | bash +``` + +Then, you have to run `git init` into your existing git repositories from your local machine (that's because the `post-commit` should be updated). This +step will not be needed after clonning a repository (the git hooks will be added automatically from `~/.git-templates`). + +#### Overriding the `git` command +One of the solutions is becoming a mad scientist, overriding the `git` command with a function. However, this may not work for you if you're using `zsh`. + If so, put the following lines in your `~/.bashrc` (or `~/.bash_profile` on OS X) file: ```sh From e3f6bd79c9974ae808925d2912494e6267fbc7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 20:08:49 +0200 Subject: [PATCH 08/11] Updated the branch --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62f6577..3f657e7 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ The way I recommend to track your git commits is to use git hooks. Run the follo ```sh # Using curl -curl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/git-hooks/scripts/init-git-post-commit | bash +curl -s https://raw.githubusercontent.com/IonicaBizau/git-stats/master/scripts/init-git-post-commit | bash # ...or wget -wget -qO- https://raw.githubusercontent.com/IonicaBizau/git-stats/git-hooks/scripts/init-git-post-commit | bash +wget -qO- https://raw.githubusercontent.com/IonicaBizau/git-stats/master/scripts/init-git-post-commit | bash ``` Then, you have to run `git init` into your existing git repositories from your local machine (that's because the `post-commit` should be updated). This From c0af83f6a3b0ca5232c6b77e008eba6a7fb6b19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 20:13:56 +0200 Subject: [PATCH 09/11] Docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f657e7..7474c82 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ $ npm install -g git-stats ``` ### Catching the `git commit` command -Would you like to catch and automatically store the commits when you do `git commit`? +Would you like to catch and automatically store the commits when you do `git commit`? If so, try one of the following solutions. #### Using `git` hooks The way I recommend to track your git commits is to use git hooks. Run the following command to initialize the `post-commit` git hook. @@ -31,7 +31,7 @@ step will not be needed after clonning a repository (the git hooks will be added #### Overriding the `git` command One of the solutions is becoming a mad scientist, overriding the `git` command with a function. However, this may not work for you if you're using `zsh`. -If so, put the following lines in your `~/.bashrc` (or `~/.bash_profile` on OS X) file: +Add the following lines in your `~/.bashrc` (or `~/.bash_profile` on OS X) file: ```sh # Override the Git command From 1f2cdf96d57d831294fd560ecd7b990a4ade8a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 21:25:55 +0200 Subject: [PATCH 10/11] Beta release. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 647ef46..c359240 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-stats", - "version": "1.0.1", + "version": "1.1.0-beta", "description": "A GitHub-like contributions calendar, but locally, with all your git commits.", "main": "lib/index.js", "bin": { @@ -34,4 +34,4 @@ "moment": "^2.9.0", "ul": "^1.1.0" } -} \ No newline at end of file +} From 5c5e8abc437a23b5440e93e317fb41a1e00a1a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 11 Feb 2015 21:41:40 +0200 Subject: [PATCH 11/11] 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c359240..2656513 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-stats", - "version": "1.1.0-beta", + "version": "1.1.0", "description": "A GitHub-like contributions calendar, but locally, with all your git commits.", "main": "lib/index.js", "bin": {