diff --git a/app/Commands/DeployProject.php b/app/Commands/DeployProject.php index c3403b244..44e621c07 100644 --- a/app/Commands/DeployProject.php +++ b/app/Commands/DeployProject.php @@ -134,9 +134,9 @@ private function updateRepoInfo() $process = new Process(sprintf( $cmd, - $this->deployment->project->branch, + $this->deployment->branch, $this->deployment->project->repository, - $this->deployment->project->branch + $this->deployment->branch )); $process->setTimeout(null); @@ -298,12 +298,12 @@ private function getScript(DeployStep $step, Server $server) sprintf('export GIT_SSH="%s"', $remote_wrapper_file), sprintf( 'git clone --branch %s --depth 1 --recursive %s %s', - $project->branch, + $this->deployment->branch, $project->repository, $latest_release_dir ), sprintf('cd %s', $latest_release_dir), - sprintf('git checkout %s', $project->branch), + sprintf('git checkout %s', $this->deployment->branch), sprintf('rm %s %s', $remote_key_file, $remote_wrapper_file) ]; } elseif ($step->stage === Stage::DO_INSTALL) { // Install composer dependencies diff --git a/app/Deployment.php b/app/Deployment.php index c35b8c2d6..059a24cda 100644 --- a/app/Deployment.php +++ b/app/Deployment.php @@ -159,7 +159,7 @@ public function notificationPayload() 'value' => $this->committer, 'short' => true ], [ - 'title' => Lang::get('notifications.branch'), + 'title' => Lang::get('notifications.proanch'), 'value' => $this->project->branch, 'short' => true ] @@ -180,4 +180,22 @@ public function getPresenter() { return new DeploymentPresenter($this); } + + /** + * Gets the HTTP URL to the branch + * + * @return string|false + * @see \App\Project::accessDetails() + * @todo Should this be an attribute? + */ + public function branchURL() + { + $info = $this->project->accessDetails(); + + if (isset($info['domain']) && isset($info['reference'])) { + return 'http://' . $info['domain'] . '/' . $info['reference'] . '/tree/' . $this->branch; + } + + return false; + } } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 84f80f454..1bca8f62b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -141,6 +141,14 @@ public function deploy(Project $project) $deployment = new Deployment; $deployment->reason = Input::get('reason'); + if (Input::has('source') && Input::has('source_' . Input::get('source'))) { + $deployment->branch = Input::get('source_' . Input::get('source')); + } + + if (empty($deployment->branch)) { + $deployment->branch = $project->branch; + } + $optional = []; if (Input::has('optional')) { diff --git a/database/migrations/2015_05_13_121650_set_deployment_branch.php b/database/migrations/2015_05_13_121650_set_deployment_branch.php new file mode 100644 index 000000000..2cf4ad790 --- /dev/null +++ b/database/migrations/2015_05_13_121650_set_deployment_branch.php @@ -0,0 +1,37 @@ +string('branch')->default('master'); + }); + + foreach (Deployment::all() as $deployment) { + $deployment->branch = $deployment->project->branch; + $deployment->save(); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('deployments', function (Blueprint $table) { + $table->dropColumn('branch'); + }); + } +} diff --git a/resources/assets/css/app.css b/resources/assets/css/app.css index 66bc07250..d2bd7bfd6 100644 --- a/resources/assets/css/app.css +++ b/resources/assets/css/app.css @@ -54,4 +54,8 @@ body.dragging * { /* Make sure there is always a space between the icon and the label as HTMLMin removes it */ span.label i.fa { margin-right: 2px; +} + +input[type=text].deployment-source { + display: none; } \ No newline at end of file diff --git a/resources/assets/js/projects.js b/resources/assets/js/projects.js index 38f9ee48b..4ec123137 100644 --- a/resources/assets/js/projects.js +++ b/resources/assets/js/projects.js @@ -1,11 +1,39 @@ var app = app || {}; (function ($) { + $('.deployment-source:radio').on('change', function (event) { + var target = $(event.currentTarget); + + $('input[type=text].deployment-source').hide(); + if (target.val() === 'branch') { + $('#deployment_branch').show(); + } else if (target.val() === 'tag') { + $('#deployment_tag').show(); + } + }); + + $('#reason').on('show.bs.modal', function (event) { + var modal = $(this); + $('.callout-danger', modal).hide(); + }); - $('#reason button').on('click', function (event) { + $('#reason button.btn-save').on('click', function (event) { var target = $(event.currentTarget); var icon = target.find('i'); var dialog = target.parents('.modal'); + var source = $('input[name=source]:checked').val(); + + $('.has-error', source).removeClass('has-error'); + + if (source === 'branch' || source === 'tag') { + if ($('#deployment_' + source).val() === '') { + $('#deployment_' + source).parentsUntil('div').addClass('has-error'); + + $('.callout-danger', dialog).show(); + event.stopPropagation(); + return; + } + } icon.addClass('fa-refresh fa-spin').removeClass('fa-save'); $('button.close', dialog).hide(); diff --git a/resources/lang/en/deployments.php b/resources/lang/en/deployments.php index 2b3851167..4f7add5ac 100644 --- a/resources/lang/en/deployments.php +++ b/resources/lang/en/deployments.php @@ -2,34 +2,40 @@ return [ - 'label' => 'Deployments', - 'latest' => 'Latest Deployments', - 'none' => 'There have not been any deployments yet.', - 'started' => 'Started', - 'deployer' => 'Deployer', - 'committer' => 'Committer', - 'commit' => 'Commit', - 'manually' => 'Manually', - 'webhook' => 'Webhook', - 'reactivate' => 'Re-activate', - 'loading' => 'Loading', - 'process' => 'Process Output', - 'server' => 'Server', - 'status' => 'Status', - 'started' => 'Started', - 'finished' => 'Finished', - 'duration' => 'Duration', - 'output' => 'View the output', - 'details' => 'Deployment Details', - 'pending' => 'Pending', - 'deploying' => 'Deploying', - 'completed' => 'Completed', - 'failed' => 'Failed', - 'running' => 'Running', - 'cancelled' => 'Cancelled', - 'loading' => 'Loading', - 'reason' => 'Reason for deployment', - 'describe_reason' => 'Please describe briefly the reason for this deployment', - 'optional' => 'Select the optional deploy steps to run' + 'label' => 'Deployments', + 'latest' => 'Latest Deployments', + 'none' => 'There have not been any deployments yet.', + 'started' => 'Started', + 'deployer' => 'Deployer', + 'committer' => 'Committer', + 'commit' => 'Commit', + 'manually' => 'Manually', + 'webhook' => 'Webhook', + 'reactivate' => 'Re-activate', + 'loading' => 'Loading', + 'process' => 'Process Output', + 'server' => 'Server', + 'status' => 'Status', + 'started' => 'Started', + 'finished' => 'Finished', + 'duration' => 'Duration', + 'output' => 'View the output', + 'details' => 'Deployment Details', + 'pending' => 'Pending', + 'deploying' => 'Deploying', + 'completed' => 'Completed', + 'failed' => 'Failed', + 'running' => 'Running', + 'cancelled' => 'Cancelled', + 'loading' => 'Loading', + 'reason' => 'Reason for deployment', + 'source' => 'Source', + 'default' => 'Default branch (:branch)', + 'different_branch' => 'A different branch', + 'tag' => 'A tag', + 'branch' => 'Branch', + 'warning' => 'The deployment could not be started, please make sure you have entered all required values.', + 'describe_reason' => 'Please describe briefly the reason for this deployment', + 'optional' => 'Select the optional deploy steps to run' ]; diff --git a/resources/lang/en/projects.php b/resources/lang/en/projects.php index daabab7c2..2328911ab 100644 --- a/resources/lang/en/projects.php +++ b/resources/lang/en/projects.php @@ -9,7 +9,7 @@ 'group' => 'Group', 'repository' => 'Repository', 'builds' => 'Builds to keep', - 'branch' => 'Branch', + 'branch' => 'Default Branch', 'image' => 'Build Image', 'latest' => 'Latest Deploy', 'create' => 'Add a new project', diff --git a/resources/views/dialogs/reason.blade.php b/resources/views/dialogs/reason.blade.php index 044e72b2a..645ee0a1b 100644 --- a/resources/views/dialogs/reason.blade.php +++ b/resources/views/dialogs/reason.blade.php @@ -9,6 +9,40 @@