Subversionでキーワードの展開をする

svnの設定を社内で標準化したいということでまとめます。
複数人でひとつの案件にかかわる時には便利な機能だと思います。

keywordとは

EC-CUBEでいうところの
~~~
プロジェクト設定

設定ファイル

http://code.google.com/p/symfony-doc-ja/wiki/SymfonyRepositoryTips
が一番わかりやすくて間違いが起きない設定だと思います。
なくなっちゃうと困るので転載しておきます
~~~
[helpers]
#diff-cmd = diff

[miscellany]
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store Thumbs.db

enable-auto-props = yes

[auto-props]
# Scriptish formats
*.bat = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.bsh = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-beanshell
*.cgi = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.cmd = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.js = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/javascript
*.php = svn:eol-style=native; svn:keywords=Id Rev Date; svn:mime-type=text/x-php
*.pl = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-perl; svn:executable
*.pm = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-perl
*.py = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-python; svn:executable
*.sh = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-sh; svn:executable

# Image formats
*.bmp = svn:mime-type=image/bmp
*.gif = svn:mime-type=image/gif
*.ico = svn:mime-type=image/ico
*.jpeg = svn:mime-type=image/jpeg
*.jpg = svn:mime-type=image/jpeg
*.png = svn:mime-type=image/png
*.tif = svn:mime-type=image/tiff
*.tiff = svn:mime-type=image/tiff

# Data formats
*.pdf = svn:mime-type=application/pdf
*.avi = svn:mime-type=video/avi
*.doc = svn:mime-type=application/msword
*.eps = svn:mime-type=application/postscript
*.gz = svn:mime-type=application/gzip
*.mov = svn:mime-type=video/quicktime
*.mp3 = svn:mime-type=audio/mpeg
*.ppt = svn:mime-type=application/vnd.ms-powerpoint
*.ps = svn:mime-type=application/postscript
*.psd = svn:mime-type=application/photoshop
*.rdf = svn:eol-style=native; svn:keywords=Id
*.rss = svn:eol-style=native; svn:keywords=Id
*.rtf = svn:mime-type=text/rtf
*.swf = svn:mime-type=application/x-shockwave-flash
*.tgz = svn:mime-type=application/gzip
*.wav = svn:mime-type=audio/wav
*.xls = svn:mime-type=application/vnd.ms-excel
*.zip = svn:mime-type=application/zip

# Text formats
.htaccess = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.css = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/css
*.dtd = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.html = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/html
*.ini = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.sql = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-sql
*.txt = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.xhtml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xhtml+xml
*.xml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xsd = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xsl = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xslt = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xul = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xul
*.yaml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.yml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
CHANGES = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
COPYING = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
INSTALL = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
Makefile* = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
README = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
TODO = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain

# Code formats
*.c = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.cpp = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.h = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.java = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
~~~

各種クライアントの設定方法

TortoiseSVN

[デスクトップを右クリック] → [TortoiseSVN] → [設定(S)] → [編集]
configファイルが開くので一番下に上に書いた設定をまるっと貼り付ける

SVN

~~~
vim ~/.subversion/config
~~~
一番下に貼り付ける

Eclipse(Subversive)

[Window] → [preferences] → [Team]→[SVN]→[Properties Configuration]

注意事項

既存のプロジェクトには反映されません。
設定をして新しくチェックアウトしたものから有効になります。

もし既存のプロジェクトにも適用したいのであれば

下記コマンドで適用をしてください
~~~
$ find . -type f -name \*.php -print0 | xargs -0 perl -i -pe “s/\r\n/\n/”
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:eol-style native
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:keywords “Id Rev Date”
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:mime-type text/x-php
~~~
Subversion設定の標準化 — ディノオープンラボラトリ

コメント

タイトルとURLをコピーしました