Skip to content

Commit

Permalink
Merge branch 'master' of github.com:meolu/walle-web
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuiyong committed Nov 19, 2015
2 parents 1f49ddb + 049ed5d commit a9b4cd0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
37 changes: 24 additions & 13 deletions components/Svn.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function updateToVersion($task) {
foreach ($copy as $file) {
$fileAndVersion[] = StringHelper::explode($file, " ", true, true);
}
$branch = $task->branch == 'trunk' ? $task->branch
// 兼容无trunk、无branches、无tags下为空
$branch = ($task->branch == 'trunk' || $task->branch == '')
? $task->branch
: ($this->getConfig()->repo_mode == Project::REPO_BRANCH ? 'branches/' : 'tags/') . $task->branch;
// 先更新
$versionSvnDir = sprintf('%s-svn', rtrim(Project::getDeployWorkspace($task->link_id), '/'));
Expand Down Expand Up @@ -75,26 +77,34 @@ public function updateToVersion($task) {
* @return array
*/
public function getBranchList() {
// 更新
$this->updateRepo();
$list = [];
$branchDir = 'tags';
if ($this->getConfig()->repo_mode == Project::REPO_BRANCH) {
$list[] = [
'id' => 'trunk',
'message' => 'trunk',
];
$branchDir = 'branches';
$trunkDir = sprintf("%s/trunk", rtrim(Project::getDeployFromDir(), '/'));

if (file_exists($trunkDir)) {
$list[] = [
'id' => 'trunk',
'message' => 'trunk',
];
} else {
$list[] = [
'id' => '',
'message' => \yii::t('w', 'default trunk'),
];
}
}
$svnType = sprintf("%s/%s", rtrim(Project::getDeployFromDir(), '/'), $branchDir);

// 更新
$this->updateRepo();
$branchDir = sprintf("%s/%s", rtrim(Project::getDeployFromDir(), '/'), $branchDir);

// 如果不存在branches目录,则跳过查找其它分支
if (!file_exists($svnType)) {
if (!file_exists($branchDir)) {
return $list;
}

$branches = new \DirectoryIterator($svnType);
$branches = new \DirectoryIterator($branchDir);
foreach ($branches as $branch) {
$name = $branch->__toString();
if ($branch->isDot() || $branch->isFile()) continue;
Expand All @@ -113,7 +123,7 @@ public function getBranchList() {
*
* @return array
*/
public function getCommitList($branch = 'master', $count = 30) {
public function getCommitList($branch = 'trunk', $count = 30) {
// 先更新
$destination = Project::getDeployFromDir();
$this->updateRepo($branch, $destination);
Expand Down Expand Up @@ -219,7 +229,8 @@ public static function formatXmlLog($xmlString) {

public static function getBranchDir($branch, $tag = false) {
$svnDir = Project::getDeployFromDir();
$branchDir = $branch == 'trunk' && !$tag
// 兼容无trunk、无branches、无tags下为空
$branchDir = ($branch == '' || $branch == 'trunk') && !$tag
? $branch
: ($tag ? 'tags/'.$branch : 'branches/'.$branch);
return sprintf('%s/%s', $svnDir, $branchDir);
Expand Down
1 change: 1 addition & 0 deletions messages/en/w.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'conf_level_2' => 'Pre-Release',
'conf_level_3' => 'Production',

'default trunk' => 'default no trunk',
'conf_status_0' => 'Invalid',
'conf_status_1' => 'Valid',
'conf_audit_0' => 'Yes',
Expand Down
1 change: 1 addition & 0 deletions messages/zh/w.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'conf_level_2' => '预发布环境',
'conf_level_3' => '线上环境',

'default trunk' => '默认无trunk',
'conf_status_0' => '无效',
'conf_status_1' => '有效',
'conf_audit_0' => '',
Expand Down
2 changes: 1 addition & 1 deletion views/task/submit-svn.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function getChangeFiles(projectId, branch, start, end) {
getBranchList();
// 页面加载完默认拉取trunk
if ($('#branch').val()) {
getCommitList();
// getCommitList();
}


Expand Down

0 comments on commit a9b4cd0

Please sign in to comment.