SVN是一个比较方便的版本管理系统,wordpress的插件就是利用该系统进行管理的,我对svn不熟悉,所以即使wp早就通过了我的cos-html-cache的插件申请,我也是最近几天才上传上去,如果你也有类似的情况,下面的内容也许对你有帮助,因为或许你也和我一样,不需要过多的关心什么是SVN,仅仅需要能将你的插件上传到WP而且今后可以编辑,仅此而已。
———————华丽的分界线——————————–
All you want to do is add the plugin files you already
have to your new repository.
所有你想要做的就是将你写好的插件文件传到wordpress的官方插件文件夹里
To do that you’ll need to
你需要做的步骤如下:
1. Check out the blank repository.从远程文件取出空白文件夹,这样你就可以清楚的了解目录结构了
2. Add your files to the trunk/ directory of your local
copy of the repository.将本地的文件放置到trunk目录下,别放目录,直接放你插件目录下的文件
3. Check in those files back to the central repository.将本地文件同步更新到远程文件
# Create a local directory on your machine to house
在本机创建一个目录作为插件的根目录
# a copy of the repository.
下面的命令解释在括号中,请大家运行命令的时候不要带上括号的内容
$ mkdir my-local-dir (进入windows的命令行 开始-〉运行->cmd,然后进入一个盘符:e:
建立一个文件夹my-local-dir )
# Check out the repository
将服务器上的文件夹结构取出
$ svn co http://svn.wp-plugins.org/your-plugin-name
my-local-dir (your-plugin-name是你成功申请的plugin name,而my-local-dir
就是你刚才建立的文件夹,运行这个命令之后,你本地的文件夹下就有一个标准的目录结构了)
> A my-local-dir/trunk
> A my-local-dir/branches
> A my-local-dir/tags
> Checked out revision 11325.
# As you can see, subversion has added ( “A” for “add”
)
# all of the directories from the central repository
to
# your local copy.
现在服务器上的插件文件夹已经下载到本机了,下一步就是复制你的插件文件
# Copy the plugin files to the local copy.
# Put everything in the trunk/ directory for now.
将所有的插件文件复制到trunk/目录下,注意,请直接复制目录下的文件,不用在trunk/再建立一级目录,席面的两行操作如果是windows,用win界面完成即可
$ cd my-local-dir/
my-local-dir/$ cp ~/my-plugin.php trunk/my-plugin.php
my-local-dir/$ cp ~/readme.txt trunk/readme.txt
# Let subversion know you want to add those new files
# back into the central repository.
接下来将你的文件夹添加到svn,即告诉svn哪些文件是要添加到服务器的
my-local-dir/$ svn add trunk/*
> A trunk/my-plugin.php
> A trunk/readme.txt
现在就将更新的文件发送到服务器上
# Now check in the changes back to the central repository.
# Give a message to the check in.
执行下面的命令将会发送文件到wordpress的服务器,’Adding first version of
my plugin’ 引号的文字只是一个message,随便你输入什么
注意:第一次使用svn发送文件的时候会提示你输入用户和密码,这个用户和密码就是你wordpress.org的注册用户和密码
my-local-dir/$ svn ci -m ‘Adding first version of my
plugin’
> Adding trunk/my-plugin.php
> Adding trunk/readme.txt
> Transmitting file data .
> Committed revision 11326.
# All done!
至此为止,插件的上传已经成功完成
Task 2: Editing a file that is already in the repository
任务2:修改已经存在的插件
We’ll assume you’ve already got your plugin repository
filled with the needed files (Task 1). Now suppose you
need to edit
one of the files to improve the plugin.
To do that you’ll need to
1. Make sure your copy of the repository is up to date.确保你当前的文件是最新的
2. Edit the file.编辑你想编辑的文件
3. Double check your changes.再次检查哪些文件发生了改变
4. Check in your changes.同步远程文件
# cd into your local copy of the repository and
# make sure it’s up to date
下面的命令是保证你的文件是最新的
$ cd my-local-dir/ (进入本地文件夹)
my-local-dir/$ svn up (检查文件是否是最新文件)
> At revision 11326.
# Good: all up to date. If there had been changes in
the
# central repository, they would have been downloaded
and
# merged into your local copy.
# Edit the file that needs changing. I use nano.
# No need for editor wars; use whatever you like.
my-local-dir/$ nano trunk/my-plugin.php (这个是在*nix系统下用nano编辑文件,如果是window,请用其他编辑器直接编辑你需要编辑的文件)
# … edit … edit … make typo … edit
# … fix typo … edit … all done.
# You can check and see what’s different between your
# local copy and the central repository.
# First we check the status of the local copy.
my-local-dir/$ svn stat (检查本地文件和svn服务器上文件的状态,该命令会显示哪些文件做了改动)
> M trunk/my-plugin.php
# This tells us that our local trunk/my-plugin.php
# is different from the copy we downloaded from the
# central repository ( “M” for “modified” ).
# Let’s see what exactly has changed in that file,
# so we can check it over and make sure things look
right.
my-local-dir/$ svn diff (这个命令是显示文件的那些部分做了改变,可以不用执行)
> * What comes out is essentially the result of a
* standard `diff -u` between your local copy and the
* original copy you downloaded.
# Looks good. Let’s check in those changes to the
# central repository.
my-local-dir/$ svn ci -m “fancy new feature: now you
can foo *and* bar at the same time” (将改动后的文件上传到服务器)
> Sending trunk/my-plugin.php
> Transmitting file data .
> Committed revision 11327.
# All done!
修改的流程已经完成
Task 3: “Tagging” a new version
tag或者归档一个旧的文件版本,如果该版本不再更新了,请用tag归档该版本
Each time you make a formal release of your plugin,
you should tag a copy of that release’s code. This lets
your users easily
grab the latest (or an older) version, it lets you
keep track of changes more easily, and lets the WordPress.org
Plugin
Directory know what version of your plugin it should
tell people to download.
To do that you’ll need to remember to update the Stable
Tag field in trunk/readme.txt beforehand!
Then you’ll
1. Copy your code to a subdirectory in the tags/ directory.
For the sake of the WordPress.org plugin browser, the
new subdirectory should always look like a version number.
2.0.1.3 is good. Cool hotness tag is bad.
2. Check in that new subdirectory.
# You’ve just checked in the latest and greatest updates
# to your plugin, let’s tag it with a version number,
2.0.
# To do that, copy the files from your trunk/ directory
to
# a new directory in tags/.
# Make sure to use `svn cp` instead of the regular `cp`.
my-local-dir/$ svn cp trunk tags/2.0 (将当前的文件copy到tag中,该例子表示tag到2.0)
> A tags/2.0
# Now, as always, check in the changes.
my-local-dir/$ svn ci -m “tagging version 2.0″ (上传改变的东西,更新svn服务器)
> Adding tags/2.0
> Adding tags/2.0/my-plugin.php
> Adding tags/2.0/readme.txt
> Committed revision 11328.
# All done! |