我正在使用一个庞大的 SVN 存储库——它由数百个目录(都在不同的深度)和数千个文件(所有不同的类型)组成。我需要对这个 repo 中包含的几百个 JavaScript 文件进行批量更新。我希望有选择地只签出 .js 文件,而不是下载整个 repo。我一直在玩一堆不同的方法,但一直无法破解它。这是我能想到的......
# CHECKOUT INITIAL WORKING COPY
svn co https://myrepo.com/site-content --depth empty
# NAVIGATE TO WORKING COPY
cd site-content
# CHECKOUT FULL DIRECTORY TREE
env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth empty $REPO'
# UPDATE WORKING COPY WITH .JS FILES
svn up `svn ls -R https://myrepo.com/site-content | grep .js$`
我在终端中得到的回复似乎表明一切正常,但是,显然情况并非如此。我留下了完整的目录树,但绝对没有 .js 文件。这是我的终端输出示例:
jakes-mac:working-copy jake$ svn co https://myrepo.com/site-content --depth empty
Checked out revision 21097.
jakes-mac:working-copy jake$ cd site-content
jakes-mac:site-content jake$ env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth empty $REPO'
Checked out revision 21098.
Checked out revision 21098.
Checked out revision 21098.
Checked out revision 21098.
Checked out revision 21098.
...
Checked out revision 21099.
Checked out revision 21099.
Checked out revision 21099.
Checked out revision 21099.
Checked out revision 21099.
jakes-mac:site-content jake$ svn up `svn ls -R https://myrepo.com/site-content | grep .js$`
Updating '2013/js/_old/script.trees.bak.rev-a.js':
At revision 21100.
Updating '2013/js/_old/script.video.bak.rev-a.js':
At revision 21100.
Updating '2013/js/script.category.js':
At revision 21100.
Updating '2013/js/script.trees.js':
At revision 21100.
Updating '2013/js/script.video-v2.js':
At revision 21100.
Updating '2013/js/script.video.js':
At revision 21100.
Updating '2014/TreeGiveaway/js/script.sweeps.js':
At revision 21100.
Updating '2014/TreeGiveaway/js/validate-voting.js':
At revision 21100.
Updating '2014/js/collectionslider.js':
At revision 21100.
Updating '2014/js/difference.js':
At revision 21100.
Updating '2014/js/mobile.js':
At revision 21100.
Updating '2014/js/script.category.js':
At revision 21100.
Updating '2014/js/script.quicklight_inset.js':
At revision 21100.
Updating '2014/js/script.trees.js':
At revision 21100.
Updating '2014/js/script.trees.v3.js':
At revision 21100.
Updating '2014/js/script.trees_inset.js':
At revision 21100.
Updating '2014/js/script.trees_inset.new.js':
At revision 21100.
Updating '2014/slideshow/js/jquery.easing.min.js':
At revision 21100.
Updating '2014/slideshow/js/script.js':
At revision 21100.
Updating '2014/slideshow/js/supersized.3.2.7.js':
At revision 21100.
Updating '2014/slideshow/js/supersized.shutter.js':
At revision 21100.
Updating '2015/js/framework.fetchFeed.js':
At revision 21100.
Updating '2015/js/framework.goModal.js':
At revision 21100.
Updating '2015/js/frameworkForMobile.js':
At revision 21100.
Updating '2015/js/script.category.js':
At revision 21100.
Updating '2015/js/script.hs.js':
At revision 21100.
Updating '2015/js/script.shop-the-scene.js':
At revision 21100.
Updating '2015/js/script.trees.js':
At revision 21100.
Updating '2015/tree-finder/results.script-v2.js':
At revision 21100.
Updating '2015/tree-finder/results.script.js':
At revision 21100.
Updating '2015/tree-finder/wizard.script.js':
At revision 21100.
Updating 'current/js/holiday-decor.js':
At revision 21100.
Updating 'current/js/how-to.js':
At revision 21100.
Updating 'current/js/shop-the-style.js':
At revision 21100.
编辑:
现在都在工作!最终命令列表:
# CHECKOUT INITIAL WORKING COPY
svn co https://myrepo.com/site-content --depth empty
# NAVIGATE TO WORKING COPY
cd site-content
# CHECKOUT FULL DIRECTORY TREE
env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | grep "/\$" | while read dir; do svn co --depth=empty $REPO/$dir $dir; done'
# UPDATE WORKING COPY WITH .JS FILES
svn up `svn ls -R https://myrepo.com/site-content | grep .js$`
# COMMIT ALL CHANGES TO REPO
svn commit `svn ls -R | grep .js$` -m "Bulk Updating Content"