git-starteam使用詳解

        git-starteam是一個將StarTeam轉換成git的工具。

        5年StarTeam和2年git的使用經歷,我對比得出StarTeam適合於管理文檔、git適合於管理代碼的結論。

       文檔不像代碼那樣需要讓所有相關的.c、.h文件同時處於一個提交點版本上以備日後比如尋找Bug時一起回溯,反而是用戶只會關心文檔的最新版、文檔本身這單獨一個文件的修改歷史以及這個文件是否能被單獨從數據庫中檢出,StarTeam滿足這些條件,而git在使用時會一次性檢出所有的文件。以前曾試驗過用網頁形式的wiki語法來寫文檔,後來發現效果不好,因爲很多網上下載的技術資料是pdf、html或doc格式的,如果讓技術人員再去將內容手工轉換成wiki格式的文本那就是捨本逐末了,而後來用StarTeam建的共享知識庫還是比較好用的。

        代碼需要經常改動許多文件才能共同完成或試驗某個功能,git的無痛分支功能正滿足了程序員的這個需求,而StarTeam的分支、合併就是一場噩夢。這幾年找過幾次將StarTeam轉換成git的工具,而發現沒有可用工具時曾試過手動將StarTeam的Label檢出再檢入git,勉強能用,但丟失了大量歷史信息,使得無法再在gitk --all圖形界面中查找某行代碼是在哪個時間點被誰修改的……

        終於,前段時間再次尋找時發現了https://github.com/planestraveler/git-starteam ,雖然還只能將StarTeam中最新版本的各個文件按照時間排序和註釋分類轉換進git、仍舊處於雛形階段,不過好在自己對StarTeam有過深入研究,並得益於github網站fork出源代碼、做出修改後發送pull request給原作者的功能,我在自己的https://github.com/flyskywhy/git-starteam 中達到了保留所有歷史信息(幾乎所有,我是用每隔24小時的View Configuration來轉換一次,而且StarTeam追溯代碼歷史的不便也使得程序員一般沒有動力在24小時內將同一個源代碼文件上傳兩次到StarTeam上)、將其它View轉換爲git中的分支、針對某個目錄進行轉換(StarTeam管理的項目中一般會將編譯工具、源代碼、文檔等分目錄存放,而git管理的項目一般會將這些分成幾個.git倉庫存放)的功能。

        git-starteam的使用方式,如我在https://github.com/flyskywhy/git-starteam/blob/master/README 中所補充描述的,在git clone https://github.com/flyskywhy/git-starteam.git 之後,按如下方式操作即可:

Build with starteam80 API:
cd ~/proj/git-starteam/
scons --jargs /usr/share/java/jargs.jar --starteam /opt/StarTeamCP_2005r2/lib/starteam80.jar bin/syncronizer.jar
(If not starteam80, maybe you should modify generateFastImportStream() in syncronizer/src/org/sync/GitImporter.java, for
 http://techpubs.borland.com/starteam/2009/en/sdk_documentation/api/com/starbase/starteam/CheckoutManager.html said old version (passed in /opt/StarTeamCP_2005r2/lib/starteam80.jar) "Deprecated. Use View.createCheckoutManager() instead.")

Prepare before Run:
In Linux, the default max "open files" is 1024 (`ulimit -a`). Maybe you will get "java.io.IOException: Too many open files" if your StarTeam project had checked in too many files in one time, then you should add "* - nofile 65536" line to /etc/security/limits.conf and re-login to shell.
In Windows, the default max "open files" is 16384.

Run with starteam80 API:
1. Create bin/.git/ folder from a StarTeam project named Prime with Prime view:
cd ~/proj/git-starteam/bin/
java -cp .:/usr/share/java/jargs.jar:/opt/StarTeamCP_2005r2/lib/starteam80.jar:./syncronizer.jar:../lib/org.eclipse.jgit-0.12.1.jar org.sync.MainEntry -h 192.0.1.102 -P 49203 -p Prime -v Prime -H master -U UserName -d gmail.com -f Src/apps/vlc2android/ -c
Or, it's a good idea to add .gitignore first, so you can do below instead:
cd ~/proj/git-starteam/bin/
echo "*.o" > .gitignore
git add .gitignore
git commit -m "Init with .gitignore"
java -cp .:/usr/share/java/jargs.jar:/opt/StarTeamCP_2005r2/lib/starteam80.jar:./syncronizer.jar:../lib/org.eclipse.jgit-0.12.1.jar org.sync.MainEntry -h 192.0.1.102 -P 49203 -p Prime -v Prime -H master -U UserName -d gmail.com -f Src/apps/vlc2android/ -R


2. Add other branch to bin/.git/ folder from other view:
In gitk --all, create OtherView branch base on the commit which time is nearest before "StarTeam->View->Properties->Type->Parent Configuration" of the Other View.
java -cp .:/usr/share/java/jargs.jar:/opt/StarTeamCP_2005r2/lib/starteam80.jar:./syncronizer.jar:../lib/org.eclipse.jgit-0.12.1.jar:/usr/lib/jvm/java-1.6.0-sun/jre/lib/ org.sync.MainEntry -h 192.0.1.102 -P 49203 -p Prime -v "Other View" -H other-view -U UserName -d gmail.com -f Src/apps/vlc2android -R

3. Get the repository:
cd /pub/gittrees/
git clone --bare ~/proj/git-starteam/bin/.git vlc2android.git

4. Delete bin/.git/ folder
cd ~/proj/git-starteam/bin/
rm .git/ -fr

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章