Posts Tagged ‘svn’

Upgraded to WordPress 2.6

July 18, 2008 Tags: ,

Upgrading with svn was so smooth and fast. Cool.

Tags on Git

June 30, 2008 Tags: , ,

Tags of SVN are just copies of trunk. Tags of Git, on the other hand, are much more powerful. Here I’ll show you how to add/delete git tags locally and remotely.

I’ll take google_map_example for example. The google_map_example is an open project on github that shows sample codes from the book Beginning Google Maps Applications with Rails and Ajax: From Novice to Professional. The codes will be changed slightly to use Rails 2.1.

Say I’ve keyed in the codes from chapter 1, now I’d like to tag the last commit. This is can be done in this way:

phantom:~/codex/maps (master) james$ git tag -a -m "tagged chap_1" chap_1
phantom:~/codex/maps (master) james$ git tag -l
chap_1

A local tag named “chap_1″ has been created. Keep in mind it’s merely a LOCAL tag, which means you have to push it to the remote repository to let other guys see it.

Here’s the tricky thing, git push won’t push the tag to the remote, git push –all won’t neither! Use this instead:

phantom:~/codex/maps (master) james$ git push --tags
updating 'refs/tags/chap_1'
  from 0000000000000000000000000000000000000000
  to   63db0052a27914db5f1a9fe6e1321309e8111f82
Generating pack...
Done counting 1 objects.
Deltifying 1 objects...
 100% (1/1) done
Writing 1 objects...
 100% (1/1) done
Total 1 (delta 0), reused 0 (delta 0)

Let’s go to the github project page to check if the tag has been pushed. Visit http://github.com/ashchan/google_maps_example/tree/master, hover mouse to “all tags”. Cheers, it’s there!

Git tag

Later I decide to remove this tag. Piece of cake, just use the git tag -d command:

phantom:~/codex/maps (master) james$ git tag -d chap_1
Deleted tag 'chap_1'
phantom:~/codex/maps (master) james$ git tag -l

Note when I use git tag -l it shows no local tags.

It’s a little bit complicated to use the push command to remove the remote tag:

phantom:~/codex/maps (master) james$ git push origin :refs/tags/chap_1
deleting 'refs/tags/chap_1'
Everything up-to-date

I googled a lot and couldn’t find any documents showing this example. Almost all people know that git push remotename :refs/heads/branchname would delete a remote branch, so it’s not very hard for me to figure out how to delete a remote tag :p

I’m new to git but I’ve been planning to migrate most projects to git. Hope this helps.

保护Rails应用的svn目录

March 29, 2008 Tags: , , ,

Rails开发者喜欢用Capistrano来自动化部署网站应用(什么,你不用?),即使不使用自动化部署,很多人也会使用svn co直接将代码取到网站应用目录。这给网站信息泄漏提供了方便。使用下面的地址,就能访问到这样的网站的svn信息:

  • http://somesite.com/.svn/entries
  • http://somesite.com/.svn/javascripts/entries

这可不大妙,因为这个文件里包含了你的svn库的地址、用户名和当前目录内容等很多信息。最好通过服务器配置来禁止对.svn目录的访问。在nginx下,可以在server配置下加入这一条:

location ~ /\.svn {
    deny    all;
}

另一种方式是在config/deploy.rb中加入以下设置,使用svn export来导出代码:

set :deploy_via, :export

不过很多时候为了手工维护站点的需要,我更倾向于用svn co(svn checkout)。

删除SVN目录SHELL命令

March 12, 2007 Tags: ,

 很多时候,需要删除SVN工作目录下的.svn目录,常用的作法是用系统(Windows)自带的搜索功能,搜索出所有.svn目录(需要在“其他高级选项”中选中“搜索隐藏的文件和文件夹”),然后全选删除。这当然不是高效的作法,谁能忍受一遍又一遍重复这种纯体力的劳动?

Jon Galloway提供了一段注册表代码,可以将”Delete SVN Folders”命名增加到资源管理器的右键上,这样,鼠标点两下就能把选中目录下的所有.svn目录干掉了。Works just great!

代码为:

Windows Registry Editor Version 5.00

[HKEYLOCALMACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEYLOCALMACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

将这段代码保存为一个.reg文件,双击确认导入注册表即可。

出自: Jon Galloway : Shell Command - Remove SVN Folders

Shell Command - Remove SVN Folders

The Subversion source control client maintains your local state in hidden folders named .svn inside your project, which can be a problem if you want to copy or share the project directory.  This REG file adds “Delete SVN Folders” to the context menu for folders. When you select it, it removes all folders named .svn inside the folder and it’s children (it does nothing if the project’s not under Subversion source control.

I’m not going to bother explaining reg file installation here - I figure if you’re using SVN, you’re good with reg files.

Linux + Apache + Subversion

April 10, 2005 Tags: , , ,

每次用Linux,都会被中途吓跑。我拥有过的几代台式机,显卡均是集成的,安装时都遇到X-Window无法启动的困难。在Console界面下学习,曲线太陡峭,所以每次都不了了之。

在小黑上成功装上Feroda Core 3。编译安装Berkeley DB 4.2、Apache 2.0.53及最新的Subversion,反复数次,最终搞定。

装软件比较麻烦的一点是不同版本的Dependency交错复杂,搞得人头昏眼花。实验机器上还好办,对于一个product server,就比较危险了。

Apache默认安装是不包含moddav模块的,除了重编译Apache,我没发现还有什么办法在后期将该模块加入Apache(编译时有两种方式,静态链入Apache,或是用一个动态模块通过配置文件来加载)。没有moddav,便不能将Subersion融到Apache中去了,只好以功能相对较弱的svnserve方式来运行。

初步使用的感受,普通工作还是Win来得舒服,Server不妨用Linux,一来便宜,二来各种软件配置的自主权比较大,三来显得比较高深。