depot_tools_tutorial.demo.walkthrough.sh 3.93 KB
Newer Older
1
#!/usr/bin/env bash
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
BLANK_DEMO=1
. demo_repo.sh

trunc() {
  echo ... truncated output ...
}

trunc_command() {
  pcommand "$@"
  trunc
}

WS=build/whitespace_file.txt
add_ws() {
  praw cat '>>' $WS '<<EOF'
  echo -e "$1"
  echo EOF
  echo -e "$1" >> $WS
}

ed_ws() {
  echo -ne "\x1B[37;1m$ echo -e "
  echo -n "'$1'"
  echo -e " | ed $WS\x1B[m"
26
  echo -e "$1" | ed $WS 2>&1
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
}

# needs an extra echo afterwards
map() {
  run git map
  echo
}

ED1='/Banana\ns/Banana/Kuun\nwq'

ADD1="
\"You recall what happened on Mulholland drive?\" The ceiling fan rotated slowly
overhead, barely disturbing the thick cigarette smoke. No doubt was left about
when the fan was last cleaned."

ED2='/Kuun\ns/Kuun/Kun\nwq'

ADD2="
There was an poignant pause."

ADD3="
CHAPTER 3:
Mr. Usagi felt that something wasn't right. Shortly after the Domo-Kun left he
began feeling sick."

trunc_command fetch chromium
pcommand cd src

comment "(only on linux)"
trunc_command ./build/install-build-deps.sh

comment "Pull in all dependencies for HEAD"
trunc_command gclient sync

comment "Let's fix something!"
run git new-branch fix_typo
ed_ws "$ED1"
run git commit -am 'Fix terrible typo.'
map
run git status
trunc_command git cl upload -r domo@chromium.org --send-mail

comment "While we wait for feedback, let's do something else."
run git new-branch chap2
run git map-branches
add_ws "$ADD1"
run git status

comment "Someone on the code review pointed out that our typo-fix has a typo :("
comment "We're still working on 'chap2' but we really want to land"
comment "'fix_typo', so let's switch over and fix it."
run git freeze
run git checkout fix_typo  2>&1
ed_ws "$ED2"
run git upstream-diff --wordwise
run git commit -am 'Fix typo for good!'
trunc_command git cl upload

comment "Since we got lgtm, let the CQ land it."
pcommand git cl set_commit
map

comment "Switch back to where we were using the nav* commands (for fun..."
comment "git checkout would work here too)"
run git map-branches
run git nav-upstream  2>&1
pcommand git nav-downstream
git nav-downstream --pick 0  2>&1
run git map-branches

comment "Now we can pick up on chapter2 where we left off."
run git thaw
run git diff
add_ws "$ADD2"
run git diff
run git commit -am 'Finish chapter 2'
map
trunc_command git cl upload -r domo@chromium.org --send-mail

comment "We poke a committer until they lgtm :)"
pcommand git cl set_commit

comment "While that runs through the CQ, let's get started on chapter 3."
comment "Since we know that chapter 3 depends on chapter 2, we'll track the"
comment "current chapter2 branch."
run git new-branch --upstream_current chap3
add_ws "$ADD3"
run git commit -am 'beginning of chapter 3'
map

comment "We haven't updated the code in a while, so let's do that now."
pcommand git rebase-update
echo Fetching origin
120
git fetch origin 2>&1 | grep -v 'stage' | sed 's+From.*+From https://upstream+'
121 122
silent git update-ref refs/remotes/origin/master stage_2
silent git tag -d $(git tag -l 'stage_*')
123
git rebase-update --no-fetch
124 125 126 127 128 129 130 131 132 133 134

comment "Well look at that. The CQ landed our typo and chapter2 branches "
comment "already and git rebase-update cleaned them up for us."
trunc_command gclient sync
map

comment "Someone on IRC mentions that they actually landed a chapter 3 already!"
comment "We should pull their changes before continuing. Brace for"
comment "a code conflict!"
pcommand git rebase-update
echo Fetching origin
135
git fetch origin 2>&1 | grep -v 'stage' | sed 's+From.*+From https://upstream+'
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
silent git tag -d $(git tag -l 'stage_*')
echo Rebasing: chap2
silent git rebase-update
echo ... lots of output, it\'s a conflict alright :\(...
run git diff

comment "Oh, well, that's not too bad. In fact... that's a terrible chapter 3!"
praw \$EDITOR "$WS"
echo "... /me deletes bad chapter 3 ..."
silent git checkout --theirs -- "$WS"
run git add "$WS"
run git diff --cached

comment "Much better"
run git rebase --continue
run git rebase-update
silent git tag -d $(git tag -l 'stage_*')
trunc_command gclient sync
map
trunc_command git cl upload