sh Wakatime Git post-commit hook

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Wakatime Git post-commit hook相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# NOTE: actually it would be nice to add something like the branch and SHA, but for the sake of demonstration I'm just using this file to feed Wakatime

# these variables are not used, but they might be useful; for someone else to play around
MESSAGE=$1
SHA=$(git rev-parse HEAD)
BRANCH=$(git symbolic-ref --short HEAD)

# give it a name
PLUGIN="githook-wakatime/0.0.1"
# read the API key
API_KEY=$(awk '/^api_key/{print $NF}' ~/.wakatime.cfg)
# make sure we stay in this directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# feed Wakatime with a file; anyone withh a better idea?
FILE="$DIR/post-commit"

# download Wakatime CLI if necessary
if [ ! -d "$DIR/wakatime" ];
then
    mkdir "$DIR/wakatime"
    wget -t 30 -w 5 --waitretry 20 --random-wait -O - https://github.com/wakatime/wakatime/archive/master.tar.gz | tar -C "$DIR/wakatime" --strip-components=1 -zxv
fi

# NOTE: in case you want to test more then enable this line
#python wakatime/wakatime-cli.py --write --verbose --logfile wakatime.log --file "$FILE" --key "$API_KEY" --plugin "$PLUGIN"

python "$DIR/wakatime/wakatime-cli.py" --write --file "$FILE" --key "$API_KEY" --plugin "$PLUGIN"

# optionally you could provide the --project parameter here to aggregate the stats in a separate project; 
# maybe there will be a better solution once Alan has implemented the categories feature

以上是关于sh Wakatime Git post-commit hook的主要内容,如果未能解决你的问题,请参考以下文章

wakatime插件记录您编码时间

IDEA插件系列(55):WakaTime插件——自动生成编程项目中的指标见解和时间跟踪

sh git_exclude.sh

sh git_lfs.sh

sh git.sh

sh 签署git commits.sh