package cn.reghao.bnt.web.devops.app.service.webhook.event;

import com.google.gson.JsonObject;
import org.springframework.stereotype.Component;

/**
 * @author reghao
 * @date 2022-05-13 13:12:05
 */
@Component
public class CodeupPushEvent implements PushEvent {
    @Override
    public BuildParam handle(JsonObject jsonObject) {
        JsonObject repoObject = jsonObject.get("repository").getAsJsonObject();
        String repo = repoObject.get("git_http_url").getAsString();
        String branch = jsonObject.get("ref").getAsString().replace("refs/heads/", "");
        String buildBy = this.getClass().getSimpleName();
        return new BuildParam(repo, branch, buildBy);
    }
}
