OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 REMOTE=$(pwd)/demo_repo |
| 4 |
| 5 unset GIT_DIR |
| 6 |
| 7 # Helper functions |
| 8 set_user() { |
| 9 export GIT_AUTHOR_EMAIL="$1@chromium.org" |
| 10 export GIT_AUTHOR_NAME="$1" |
| 11 export GIT_COMMITTER_EMAIL="$1@chromium.org" |
| 12 export GIT_COMMITTER_NAME="$1" |
| 13 } |
| 14 set_user 'local' |
| 15 |
| 16 |
| 17 # increment time by X seconds |
| 18 TIME=1397119976 |
| 19 tick() { |
| 20 TIME=$[$TIME + $1] |
| 21 export GIT_COMMITTER_DATE="$TIME +0000" |
| 22 export GIT_AUTHOR_DATE="$TIME +0000" |
| 23 } |
| 24 tick 0 |
| 25 |
| 26 # a commit |
| 27 c() { |
| 28 silent git commit --allow-empty -m "$1" |
| 29 tick 10 |
| 30 } |
| 31 |
| 32 praw() { |
| 33 echo -e "\x1B[37;1m$ $@\x1B[m" |
| 34 } |
| 35 |
| 36 # print a visible command (but don't run it) |
| 37 pcommand() { |
| 38 praw "$(python -c '\ |
| 39 import sys, pipes; \ |
| 40 print " ".join(map(pipes.quote, sys.argv[1:]))' "$@")" |
| 41 } |
| 42 |
| 43 # run a visible command |
| 44 run() { |
| 45 pcommand "$@" |
| 46 "$@" |
| 47 } |
| 48 |
| 49 comment() { |
| 50 echo "# $@" |
| 51 } |
| 52 |
| 53 # run a silent command |
| 54 silent() { |
| 55 if [[ $DEBUG ]] |
| 56 then |
| 57 "$@" |
| 58 else |
| 59 "$@" > /dev/null 2> /dev/null |
| 60 fi |
| 61 } |
| 62 |
| 63 # add a file with optionally content |
| 64 add() { |
| 65 local CONTENT=$2 |
| 66 if [[ ! $CONTENT ]] |
| 67 then |
| 68 CONTENT=$(python -c 'import random, string; \ |
| 69 print "".join(random.sample(string.lowercase, 16))') |
| 70 fi |
| 71 echo "$CONTENT" > $1 |
| 72 silent git add $1 |
| 73 } |
| 74 |
| 75 # Add a special callout marker at the given line offset to indicate to |
| 76 # filter_demo_output.py to add a callout at that offset. |
| 77 callout() { |
| 78 echo -e "\x1b[${1}c" |
| 79 } |
OLD | NEW |