| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # A convenience script to largely replicate the behavior of `gclient sync` in a | 6 # A convenience script to largely replicate the behavior of `gclient sync` in a |
| 7 # submodule-based checkout. Fetches latest commits for top-level solutions; | 7 # submodule-based checkout. Fetches latest commits for top-level solutions; |
| 8 # updates submodules; and runs post-sync hooks. | 8 # updates submodules; and runs post-sync hooks. |
| 9 | 9 |
| 10 export GIT_MERGE_AUTOEDIT=0 | 10 export GIT_MERGE_AUTOEDIT=0 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 serial_update() { | 47 serial_update() { |
| 48 ( cd "$1" | 48 ( cd "$1" |
| 49 $GIT_EXE $pull $pull_args -q origin | sed "s/^/[$1] /g" | 49 $GIT_EXE $pull $pull_args -q origin | sed "s/^/[$1] /g" |
| 50 if [ $? -ne 0 ]; then | 50 if [ $? -ne 0 ]; then |
| 51 return $? | 51 return $? |
| 52 fi | 52 fi |
| 53 $GIT_EXE submodule --quiet sync | 53 $GIT_EXE submodule --quiet sync |
| 54 $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' | | 54 $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' | |
| 55 while read submod; do | 55 while read submod; do |
| 56 $GIT_EXE submodule update --init "$submod" | sed "s|^|[$1/$submod] |g" | 56 "$crup_runner" "$1/$submod" |
| 57 done | 57 done |
| 58 ) | 58 ) |
| 59 } | 59 } |
| 60 | 60 |
| 61 while test $# -ne 0; do | 61 while test $# -ne 0; do |
| 62 case "$1" in | 62 case "$1" in |
| 63 -j[0-9]*) | 63 -j[0-9]*) |
| 64 j=$(echo "$1" | cut -c3-) | 64 j=$(echo "$1" | cut -c3-) |
| 65 ;; | 65 ;; |
| 66 --jobs=[0-9]*) | 66 --jobs=[0-9]*) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if ( echo test test | xargs -P 2 true 2>/dev/null ); then | 112 if ( echo test test | xargs -P 2 true 2>/dev/null ); then |
| 113 xargs_parallel=yes | 113 xargs_parallel=yes |
| 114 else | 114 else |
| 115 if test "$j" != "1"; then | 115 if test "$j" != "1"; then |
| 116 echo "Warning: parallel execution is not supported on this platform." 1>&2 | 116 echo "Warning: parallel execution is not supported on this platform." 1>&2 |
| 117 fi | 117 fi |
| 118 xargs_parallel=no | 118 xargs_parallel=no |
| 119 fi | 119 fi |
| 120 | 120 |
| 121 set -o pipefail | 121 set -o pipefail |
| 122 | |
| 123 if test "$xargs_parallel" = "yes"; then | 122 if test "$xargs_parallel" = "yes"; then |
| 124 ( ls -d */.git | sed 's/\/\.git$//' | | 123 ( ls -d */.git | sed 's/\/\.git$//' | |
| 125 xargs $max_lines $replace_arg -P "$j" \ | 124 xargs $max_lines $replace_arg -P "$j" \ |
| 126 "$crup_runner" replace_arg $GIT_EXE $pull $pull_args -q origin | | 125 "$crup_runner" replace_arg $GIT_EXE $pull $pull_args -q origin | |
| 127 xargs $max_lines -P "$j" "$crup_runner" ) | 126 xargs $max_lines -P "$j" "$crup_runner" ) |
| 128 else | 127 else |
| 129 ls -d */.git | | 128 ls -d */.git | |
| 130 while read gitdir; do | 129 while read gitdir; do |
| 131 serial_update "${gitdir%%/.git}" | 130 serial_update "${gitdir%%/.git}" |
| 132 done | 131 done |
| 133 fi | 132 fi |
| 134 | 133 |
| 135 status=$? | 134 status=$? |
| 136 | 135 |
| 137 if [ "$hooks" = "yes" -a "$status" -eq 0 ]; then | 136 if [ "$hooks" = "yes" -a "$status" -eq 0 ]; then |
| 138 "$runhooks" | 137 "$runhooks" |
| 139 status=$? | 138 status=$? |
| 140 fi | 139 fi |
| 141 | 140 |
| 142 echo | 141 echo |
| 143 exit $status | 142 exit $status |
| OLD | NEW |