Created
May 16, 2012 08:29
-
-
Save momo-lab/2708705 to your computer and use it in GitHub Desktop.
Eclipseのプロジェクト/Subversion/Gitのルートに移動するWindows用バッチファイル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM プロジェクトのルートディレクトリに移動する。 | |
REM PUSHDしてあるので、元のディレクトリに戻りたい場合はPOPDすればよい。 | |
REM | |
REM ルートディレクトリの定義(上位ほど優先順位高) | |
REM .projectファイルがある(Eclipseのプロジェクトルート) | |
REM .gitディレクトリがある(gitのルート) | |
REM .svnディレクトリがあるtrunkディレクトリ(svnのルート) | |
PUSHD . | |
:LOOP | |
CALL :IS_PROJECT_ROOT | |
IF ERRORLEVEL 1 ( | |
CD %CD% | |
EXIT /B 0 | |
) | |
REM ドライブのルートディレクトリまで来てしまったら止める | |
IF "%CD:~-2,1%" == ":" GOTO :END_LOOP | |
CD .. | |
GOTO :LOOP | |
:END_LOOP | |
POPD | |
GOTO :EOF | |
:IS_PROJECT_ROOT | |
CALL :IS_ECLIPSE_PROJECT_ROOT %CD% | |
IF ERRORLEVEL 1 EXIT /B 1 | |
CALL :IS_GIT_PROJECT_ROOT %CD% | |
IF ERRORLEVEL 1 EXIT /B 1 | |
CALL :IS_SVN_PROJECT_ROOT %CD% | |
IF ERRORLEVEL 1 EXIT /B 1 | |
EXIT /B 0 | |
GOTO :EOF | |
:IS_ECLIPSE_PROJECT_ROOT | |
IF EXIST %1\.project EXIT /B 1 | |
EXIT /B 0 | |
GOTO :EOF | |
:IS_GIT_PROJECT_ROOT | |
IF EXIST %1\.git\CON EXIT /B 1 | |
EXIT /B 0 | |
GOTO :EOF | |
:IS_SVN_PROJECT_ROOT | |
IF NOT EXIST %1\.svn\CON EXIT /B 0 | |
IF "%~nx1" == "trunk" EXIT /B 1 | |
EXIT /B 0 | |
GOTO :EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment