diff options
| author | typebrook <typebrook@gmail.com> | 2020-05-12 22:08:17 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-05-12 22:13:34 +0800 |
| commit | b0939df4c09fe7f9097e9f5d0a328037ff6928c3 (patch) | |
| tree | 8f0b78a0231391b5c7f2f09ffd40f5179ca54b1e | |
| parent | 1620005e335d3959630c7c19fdaa9417e3b989d7 (diff) | |
Use simpler way to clone repo in background
And this way also do not need to export variables into new bash instance
| -rwxr-xr-x | gist | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -475,10 +475,9 @@ _pull_if_needed() { | |||
| 475 | cd "$repo" \ | 475 | cd "$repo" \ |
| 476 | && [[ $blob_code_local != "$blob_code" ]] \ | 476 | && [[ $blob_code_local != "$blob_code" ]] \ |
| 477 | && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ | 477 | && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ |
| 478 | && git pull | 478 | && git pull & |
| 479 | done | 479 | done |
| 480 | } | 480 | } |
| 481 | export -f _pull_if_needed | ||
| 482 | 481 | ||
| 483 | # Update local git repos | 482 | # Update local git repos |
| 484 | _sync_repos() { | 483 | _sync_repos() { |
| @@ -493,7 +492,9 @@ _sync_repos() { | |||
| 493 | 492 | ||
| 494 | # if repo is cloned, do 'git pull' if remote repo has different blob objects | 493 | # if repo is cloned, do 'git pull' if remote repo has different blob objects |
| 495 | sed -ne '/^\t/ s/\t//p' <<<$result \ | 494 | sed -ne '/^\t/ s/\t//p' <<<$result \ |
| 496 | | xargs -I{} --max-procs 8 bash -c '_pull_if_needed {}' | 495 | | while read GIST_ID; do |
| 496 | _pull_if_needed $GIST_ID | ||
| 497 | done | ||
| 497 | } | 498 | } |
| 498 | } | 499 | } |
| 499 | 500 | ||