Tweet

yellowdevils

日々すごい眠い。。。

SVN Creater

without comments

今更ですが、SVNを使う機会が増えたのですが

レポジトリを作るコマンドをスーパー忘れてしまうので

やっつけでレポジトリ作るだけのWEB/IFを作りました。
svn.php

<?php

//etc/httpd/conf.d/subvarsion.conf
define('_SVN_DIR_','/var/www/svn/');
define('_BASE_DIR_','/repos/');

//which svn
define('_PATH_','/usr/bin/');

if($_POST['name']){
$dir = _SVN_DIR_.$_POST['name'];
system(_PATH_.'svnadmin create '.$dir,$ret);
system(_PATH_.'svn mkdir -m "layout creation" file://'.$dir.'/trunk file://'.$dir.'/tags file://'.$dir.'/branches',$ret);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SVN</title>
</head>

<body>
<h1>SVN-Create</h1>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="name" id="name" />
</label>
<label>
<input type="submit" value="create" />
</label>
</form>
<?php if($_POST['name']){ ?>
<pre>
http://<?php echo $_SERVER['HTTP_HOST']._BASE_DIR_.$_POST['name'] ?>

svn import -m "initial import" /home/<?php echo $_POST['name'] ?>/ http://<?php echo $_SERVER['HTTP_HOST']._BASE_DIR_.$_POST['name'] ?>/trunk
mv /home/<?php echo $_POST['name'] ?> /home/<?php echo $_POST['name'] ?>_org
svn co http://<?php echo $_SERVER['HTTP_HOST']._BASE_DIR_.$_POST['name'] ?>/trunk <?php echo $_POST['name'] ?>

rmdir -rf /home/<?php echo $_POST['name'] ?>

</pre>
<?php } ?>
<h1>SVN-List</h1>
<ul>
<?php

if ($dh = opendir(_SVN_DIR_)) {
while ( ($file = readdir($dh)) !== false ) {
if(is_dir(_SVN_DIR_.$file) && $file != '.' && $file != '..') {
?>
<li><a href="http://<?php echo $_SERVER['HTTP_HOST']._BASE_DIR_.$file ?>"><?php echo $file ?></a></li>
<?php
}
}
closedir($dh);
}

?>
</ul>

</body>
</html>


利用は自己責任でおねがいします〜



Written by satoumizu

5月 7th, 2010 at 12:44 am

Posted in develop