WP插件开发:自动提交到svn的一个脚本
在我写Wordpress插件latex2html过程中, 需要提交到WP的插件目录, 下面这个宏可以实现提交.
此外, 若svn目录不存在, 则还会创建svn目录并获取远程版本库.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 |
#!/bin/bash # This script will submit latex2html to wp plugin directory sdir_default='/cygdrive/c/USBWEBS/root/wordpress/wp-content/plugins/latex2html' svn_default='/home/VanAbel/latex2html' tag_default='2.0.6' read -p "Input the source directory [$sdir_default]: " sdir sdir=${sdir:-$sdir_default} read -p "Input the svn directory [$svn_default]: " svn svn=${svn:-$svn_default} if [ ! -d "$sdir" ]; then echo "$sdir does not exist!" else if [ ! -d "$svn" ]; then echo "$svn does not exist!" read -p "Do you want to create?[Y/n]" createsvn createsvn=${createsvn:-Y} if [ "$createsvn" == "Y" ]; then mkdir -p $svn echo "Input the plugin directory name on wordpress, e.g." echo "if you input latex2html, then your repository will be" echo "https://plugins.svn.wordpress.org/latex2html" read -p "Your plugin directory name on wordpress:" plugname repo="https://plugins.svn.wordpress.org/$plugname" echo "==============SVN Checkout==============" svn co $repo $svn echo "==Please run the script again to submit==" fi else pushd $svn echo "===============SVN Update===============" # Get the newest remote version svn up echo "==========SVN Update Complete===========" echo echo "=========1. Back up trunk to tags=======" read -p "Which tag you want to use? [$tag_default]: " tag tag=${tag:-2.0.6} while [ -d "tags/$tag" ] do read -p "$tag exits, are you sure to continue? [y/N]: " removetag removetag=${removetag:-N} if [ "$removetag" == "N" ]; then read -p "Enter new tag you want to use: " tag tag=${tag} else # Remove the tags if exists svn rm --force tags/$tag break fi done # Backup current trunk to new tags svn cp trunk tags/$tag svn ci -m "tagging version $tag" echo "=========2. Copy source to trunk========" # Remove the trunk content svn rm --force trunk/* cp -r $sdir/* trunk/ svn add trunk/* # Show the status and difference svn stat svn diff echo "====3. Submit to wp plugin directory====" svn ci -m "New version $tag" popd fi fi |
本作品采用创作共用版权协议, 要求署名、非商业用途和保持一致. 转载本站内容必须也遵循署名-非商业用途-保持一致的创作共用协议.
发表回复