SvnPeer.php
コードをコピー コードは次のとおりです:
/**
*
* svn の外部プログラムを実行するためのクラス
*
* @auth Seven Yang
*
*/
class SvnPeer
{
/**
* リポジトリ内のディレクトリ エントリを一覧表示します
*
* @param 文字列 特定のプロジェクト リポジトリ パス
* @return bool 検証が成功した場合は true、それ以外の場合は false
*/
static public function ls($リポジトリ)
{
$command = "svn ls " . $リポジトリ;
$output = SvnPeer::runCmd($command);
$output = implode("
", $output);
if (strpos($output, 'そのリビジョンには存在しません')) {
return false;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
/**
* 履歴を記憶しながら、作業コピーまたはリポジトリ内の何かを複製します
*
* @param $src
* @param $dst
* @param $comment 文字列でログ メッセージを指定します
* @return bool true、コピーが成功した場合、それ以外の場合はエラー メッセージを返します
*
* @todo コメントには svn commit
の追加ラッシュが必要です*/
static public function copy($src, $dst, $comment)
{
$command = "svn cp $src $dst - m '$コメント'";
$output = SvnPeer::runCmd($command);
$output = implode("
", $output);
if (strpos($output, 'コミットされたリビジョン')) {
return true;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
/**
* バージョン管理からファイルとディレクトリを削除します
*
* @param $url
* @return bool 削除が成功した場合は true、それ以外の場合はエラー メッセージを返します
*
* @ todo コメントには svn commit
のラッシュを追加する必要があります*/
static public function delete($url, $comment)
{
$command = "svn del $url -m '$comment' ";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'コミットされたリビジョン')) {
return true;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
/**
* 作業コピーまたはリポジトリ内の何かを移動したり、名前を変更したりします
*
* @param $src string トランク パス
* @param $dst string 新しいブランチ パス
* @param $comment文字列 ログメッセージを指定します
* @return bool 移動が成功した場合は true、それ以外の場合はエラーメッセージを返します
*
* @todo コメントには svn commit
にラッシュを追加する必要があります*/
static public function move($src, $dst, $comment)
{
$command = "svn mv $src $dst - m '$コメント'";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'コミットされたリビジョン')) {
return true;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
/**
* バージョン管理下に新しいディレクトリを作成します
*
* @param $url string
* @param $comment string svn メッセージ
* @return bool 作成に成功した場合は true、それ以外の場合は trueエラーメッセージを返します
*
* @todo コメントには svn commit
にラッシュを追加する必要があります*/
static public function mkdir($url, $comment)
{
$command = "svn mkdir $url -m '$comment' ";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'コミットされたリビジョン')) {
return true;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
static public function diff($pathA, $pathB)
{
$output = SvnPeer::runCmd("svn diff $pathA $pathB");
return implode('
', $output);
}
static public function checkout($url, $dir)
{
$command = "cd $dir && svn co $url";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strstr($output, 'チェックアウトされたリビジョン')) {
return true;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
static public function update($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
preg_match_all("/[0-9] /", $output, $ret);
if (!$ret[0][0]){
return "
" 。 $コマンド 。 "
" 。 $output;
}
return $ret[0][0];
}
static public function merge($revision, $url, $dir)
{
$command = "cd $dir && svn merge -r1:$revision $url";
$output = implode('
', SvnPeer::runCmd($command));
if (strstr($output, 'テキストの競合')) {
return 'コマンド: ' . $command .'
'。 $output;
}
true を返します。
}
static public function commit($dir, $comment)
{
$command = "cd $dir && svn commit -m'$comment'";
$output = implode('
', SvnPeer::runCmd($command));
if (strpos($output, 'コミットされたリビジョン') || empty($output)) {
return true;
}
return $output;
}
static public function getStatus($dir)
{
$command = "cd $dir && svn st";
return SvnPeer::runCmd($command);
}
static public function hasConflict($dir)
{
$output = SvnPeer::getStatus($dir);
foreach ($output as $line){
if ('C' == substr(trim($line), 0, 1) || ('!' == substr(trim($line), 0, 1))){
true を返します。
}
}
false を返します。
}
/**
* 一連のパスのログ メッセージを XML で表示します
*
* @param パス文字列
* @return ログ メッセージ文字列
*/
static public function getLog($path)
{
$command = "svn log $path --xml";
$output = SvnPeer::runCmd($command);
return implode('', $output);
}
static public function getPathRevision($path)
{
$command = "svn info $path --xml";
$output = SvnPeer::runCmd($command);
$string = implode('', $output);
$xml = 新しい SimpleXMLElement($string);
foreach ($xml->entry[0]->attributes() as $key=>$value){
if ('revision' == $key) {
return $value ;
}
}
}
static public function getHeadRevision($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
preg_match_all("/[0-9] /", $output, $ret);
if (!$ret[0][0]){
return "
" 。 $コマンド 。 "
" 。 $output;
}
return $ret[0][0];
}
/**
* cmd を実行し、結果を返します
*
* @param string コマンドライン
* @param boolen true は SVN 認証を追加する必要があります
* @return 配列 svn の出力の内容
を実行*/
静的保護関数 runCmd($command)
{
$authCommand = ' --username ' . SVN_USERNAME 。 「 --password 」。 SVN_PASSWORD 。 ' --no-auth-cache --non-interactive --config-dir '.SVN_CONFIG_DIR.'.subversion';
exec($command . $authCommand . " 2>&1", $output);
$output を返す;
}
}

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

SublimeText3 中国語版
中国語版、とても使いやすい
