Commit 7ee4a3ed authored by cmosh's avatar cmosh

Merge branch 'feature/interrupt' into develop

Finished interrupt feature
parents 8ac73498 c725d726
......@@ -14,3 +14,5 @@ debian/*/*
.timelog-feature-finish_fix
.seconds-feature-finish_fix
.timelog-feature-finish_fix
.seconds-feature-interrupt
.timelog-feature-interrupt
......@@ -201,7 +201,7 @@ cmd_start() {
parse_args "$@"
BASE=${2:-$DEVELOP_BRANCH}
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
require_branch_absent "$BRANCH"
......@@ -222,7 +222,7 @@ cmd_start() {
die "Could not create feature branch '$BRANCH'"
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
......@@ -370,12 +370,15 @@ cmd_finish() {
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)
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")
git commit --allow-empty -m "$BRANCH was completed on $(date), total time taken:$FINALTIME expectde time was $TIME_EXPECTED"
TIME_EXPECTED=$(head -n 1 .timelog-feature-$NAME)
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, Time spent on breaks was $TOTAL_TIME_OFF"
# when no merge conflict is detected, just clean up the feature branch
......@@ -599,6 +602,54 @@ cmd_pause() {
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_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
......@@ -621,12 +672,37 @@ cmd_resume() {
# sanity checks
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 branch -D "$BRANCH-paused"
git commit --allow-empty -m "$BRANCH/Back to Work at:$(date)"
git commit --allow-empty -m "$BRANCH/Back to Work at:$(date) Time off:$TIME_OFF, Reason: $INTERRUPT_REASON"
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