Skip to content

Commit

Permalink
webhook: Fix commit push hook check bug
Browse files Browse the repository at this point in the history
See: Yona Github issue #307
  • Loading branch information
doortts committed Oct 3, 2017
1 parent a4cd776 commit 1fca910
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
9 changes: 5 additions & 4 deletions app/controllers/ProjectApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import models.enumeration.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.mail.HtmlEmail;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down Expand Up @@ -1252,10 +1253,10 @@ public static Result newWebhook(String ownerId, String projectName) {
return badRequest(ErrorViews.BadRequest.render());
}

Webhook.create(project.id,
addWebhookForm.field("payloadUrl").value(),
addWebhookForm.field("secret").value(),
Boolean.valueOf(addWebhookForm.field("gitPushOnly").value()));
Webhook webhook = addWebhookForm.get();

Webhook.create(project.id, webhook.payloadUrl, webhook.secret,
BooleanUtils.toBooleanDefaultIfNull(webhook.gitPushOnly, false));

return redirect(routes.ProjectApp.webhooks(project.owner, project.name));
}
Expand Down
12 changes: 12 additions & 0 deletions app/models/Webhook.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,16 @@ public void delete(Long projectId) {
targetProject.update();
super.delete();
}

@Override
public String toString() {
return "Webhook{" +
"id=" + id +
", project=" + project +
", payloadUrl='" + payloadUrl + '\'' +
", secret='" + secret + '\'' +
", gitPushOnly=" + gitPushOnly +
", createdAt=" + createdAt +
'}';
}
}
9 changes: 9 additions & 0 deletions app/models/enumeration/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ public boolean isCreating() {
return false;
}
}

@Override
public String toString() {
return "EventType{" +
"descr='" + descr + '\'' +
", order=" + order +
", messageKey='" + messageKey + '\'' +
'}';
}
}
9 changes: 7 additions & 2 deletions app/views/project/partial_webhooks_list.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<div class="span8 payload-url">
<strong>@Messages("project.webhook.payloadUrl")</strong>
</div>
<div class="span4 secret">
<strong>@Messages("project.webhook.secret")</strong>
<div class="span4 secret">
<strong>@Messages("project.webhook.secret") / Working only when Git push</strong>
</div>
</div>

Expand All @@ -53,6 +53,11 @@ <h6 class="mr20 truncate">
@webhook.secret
</span>
</td>
<td>
<span class="webhook-secret truncate">
<input type="checkbox" @if(webhook.gitPushOnly){checked} onclick="return false;" />
</span>
</td>
<td class="actions">
<button type="button" class="ybtn ybtn-danger ybtn-small" data-request-method="delete" data-request-uri="@routes.ProjectApp.deleteWebhook(project.owner, project.name, webhook.id)">
@Messages("button.delete")
Expand Down
20 changes: 3 additions & 17 deletions app/views/project/webhooks.scala.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
@**
* Yobi, Project Hosting SW
* Yona, 21st Century Project Hosting SW
*
* Copyright 2015 NAVER Corp.
* http://yobi.io
*
* @author Jihwan Chun
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp.
* https://yona.io
**@
@(message: String, webhooks: List[models.Webhook], project:Project)

Expand Down

0 comments on commit 1fca910

Please sign in to comment.