Commit c725d726 authored by cmosh's avatar cmosh

Interrupt feature

parent 322bea17
...@@ -201,7 +201,7 @@ cmd_start() { ...@@ -201,7 +201,7 @@ cmd_start() {
parse_args "$@" parse_args "$@"
BASE=${2:-$DEVELOP_BRANCH} BASE=${2:-$DEVELOP_BRANCH}
require_name_arg require_name_arg
echo ".seconds-feature-$NAME\n.timelog-feature-$NAME" >> .gitignore echo ".seconds-feature-$NAME\n.timelog-feature-$NAME\n.breaktime-feature-$NAME" >> .gitignore
# sanity checks # sanity checks
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
...@@ -222,7 +222,7 @@ cmd_start() { ...@@ -222,7 +222,7 @@ cmd_start() {
die "Could not create feature branch '$BRANCH'" die "Could not create feature branch '$BRANCH'"
fi fi
echo "How long do you think this feature will take(in hours)?" echo "How long do you think this feature will take (HH:MM:SS)?"
read TIME_REQUIRED read TIME_REQUIRED
...@@ -370,12 +370,15 @@ cmd_finish() { ...@@ -370,12 +370,15 @@ cmd_finish() {
echo "$TIME_USED" >> ".seconds-feature-$NAME" echo "$TIME_USED" >> ".seconds-feature-$NAME"
TOTAL_BREAK_TIME=$(awk '{ sum += $1 } END { print sum }' .breaktime-feature-$NAME)
TOTAL_TIME=$(awk '{ sum += $1 } END { print sum }' .seconds-feature-$NAME) TOTAL_TIME=$(awk '{ sum += $1 } END { print sum }' .seconds-feature-$NAME)
TIME_EXPECTED=$(head -n 1 .timelog-feature-$NAME) TIME_EXPECTED=$(head -n 1 .timelog-feature-$NAME)
seconds=$TOTAL_TIME; FINALTIME=$((seconds/86400))" days "$(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") FINALTIME=$((TOTAL_TIME/86400))" days "$(date -d "1970-01-01 + $TOTAL_TIME TOTAL_TIME" "+%H hours %M minutes %S seconds")
TOTAL_TIME_OFF=$((TOTAL_BREAK_TIME/86400))" days "$(date -d "1970-01-01 + $TOTAL_BREAK_TIME TOTAL_BREAK_TIME" "+%H hours %M minutes %S seconds")
git commit --allow-empty -m "$BRANCH was completed on $(date), total time taken:$FINALTIME expectde time was $TIME_EXPECTED"
git commit --allow-empty -m "$BRANCH was completed on $(date), total time taken:$FINALTIME expectde time was $TIME_EXPECTED, Time spent on breaks was $TOTAL_TIME_OFF"
# when no merge conflict is detected, just clean up the feature branch # when no merge conflict is detected, just clean up the feature branch
...@@ -614,6 +617,53 @@ cmd_pause() { ...@@ -614,6 +617,53 @@ cmd_pause() {
} }
cmd_interrupt() {
parse_args "$@"
require_name_arg
# sanity checks
require_branch "$BRANCH"
require_branch_absent "$BRANCH-paused"
echo $(date +%s) >> ".timelog-feature-$NAME"
LAST_LINE="$(wc -l < .timelog-feature-$NAME)"
PREV_LINE=$((LAST_LINE-1))
LAST_TIME=$(sed "${LAST_LINE}q;d" .timelog-feature-$NAME)
PREV_TIME=$(sed "${PREV_LINE}q;d" .timelog-feature-$NAME)
TIME_USED=$((LAST_TIME-PREV_TIME))
echo "$TIME_USED" >> ".seconds-feature-$NAME"
touch .interrupt-feature-$NAME
seconds=$TIME_USED; TIMESTAMP=$((seconds/86400))" days "$(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds")
git add --all .
git commit -m "$BRANCH/WIP"
git commit --allow-empty -m "$BRANCH/WIP You were disturbed on $(date), time taken so far:$TIMESTAMP"
git checkout --orphan "$BRANCH-paused"
git reset -- *
echo
echo "Summary of actions:"
echo "- Created orphan branch called '$BRANCH-paused'"
echo "- You are now free to take a break, you have spent $TIMESTAMP in this session"
echo ""
echo "Now, have some coffee and when you are done, use:"
echo ""
echo " git flow feature resume $BRANCH"
echo
}
cmd_resume() { cmd_resume() {
parse_args "$@" parse_args "$@"
...@@ -622,12 +672,37 @@ cmd_resume() { ...@@ -622,12 +672,37 @@ cmd_resume() {
# sanity checks # sanity checks
require_branch "$BRANCH" require_branch "$BRANCH"
if [ -f .interrupt-feature-$NAME ];
then
echo "Why were you interrupted?"
read INTERRUPT_REASON
rm .interrupt-feature-$NAME
else
INTERRUPT_REASON="No reason :)"
fi
LAST_LINE="$(wc -l < .timelog-feature-$NAME)"
LAST_TIME=$(date +%s)
PREV_TIME=$(sed "${LAST_LINE}q;d" .timelog-feature-$NAME)
BREAK_TIME=$((LAST_TIME-PREV_TIME))
echo "$BREAK_TIME" >> ".breaktime-feature-$NAME"
seconds=$BREAK_TIME; TIME_OFF=$((seconds/86400))" days "$(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds")
git reset -- *
git add .gitignore
git checkout "$BRANCH" git checkout "$BRANCH"
git branch -D "$BRANCH-paused" git branch -D "$BRANCH-paused"
git commit --allow-empty -m "$BRANCH/Back to Work at:$(date) Time off:$TIME_OFF, Reason: $INTERRUPT_REASON"
git commit --allow-empty -m "$BRANCH/Back to Work at:$(date)"
echo $(date +%s) >> ".timelog-feature-$NAME" echo $(date +%s) >> ".timelog-feature-$NAME"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment