Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
703ee0fb87 | ||
|
|
ee39e29269 |
@@ -64,12 +64,16 @@ public class App : IApp
|
||||
return 0;
|
||||
}
|
||||
|
||||
var isCodeFreezePeriod = _settings.ReleaseCodeFreeze != "true";
|
||||
var isCodeFreezePeriod = _settings.ReleaseCodeFreeze == "true";
|
||||
var periodDescription = isCodeFreezePeriod ? "Code-Freeze. Restrictions may apply" : "Normal";
|
||||
Console.WriteLine($"Current period is {periodDescription}.");
|
||||
|
||||
approversDict = FilterApprovers(approversDict, isCodeFreezePeriod);
|
||||
if (!await IsApproved(mergeRequest, commit, approversDict))
|
||||
var filtered = FilterApprovers(approversDict, isCodeFreezePeriod);
|
||||
if (!filtered.Any() && isCodeFreezePeriod)
|
||||
{
|
||||
filtered = FilterApprovers(approversDict, false);
|
||||
}
|
||||
if (!await IsApproved(mergeRequest, commit, filtered))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using GitLabApiClient.Models.Issues.Responses;
|
||||
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||
using GitLabApiClient.Models.Milestones.Responses;
|
||||
using GitLabApiClient.Models.Pipelines.Responses;
|
||||
using GitLabApiClient.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace Approve.Checker.Gitlab.Dto
|
||||
{
|
||||
public sealed class CustomMergeRequest
|
||||
{
|
||||
[JsonProperty("iid")]
|
||||
public int Iid { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonProperty("created_at")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("updated_at")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
[JsonProperty("labels")]
|
||||
public List<string> Labels { get; } = new List<string>();
|
||||
|
||||
[JsonProperty("source_branch")]
|
||||
public string SourceBranch { get; set; }
|
||||
|
||||
[JsonProperty("downvotes")]
|
||||
public int Downvotes { get; set; }
|
||||
|
||||
[JsonProperty("author")]
|
||||
public Assignee Author { get; set; }
|
||||
|
||||
[JsonProperty("assignee")]
|
||||
public Assignee Assignee { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("force_remove_source_branch")]
|
||||
public bool? ForceRemoveSourceBranch { get; set; }
|
||||
|
||||
[JsonProperty("milestone")]
|
||||
public Milestone Milestone { get; set; }
|
||||
|
||||
[JsonProperty("merge_status")]
|
||||
public MergeStatus Status { get; set; }
|
||||
|
||||
[JsonProperty("merge_commit_sha")]
|
||||
public string MergeCommitSha { get; set; }
|
||||
|
||||
[JsonProperty("merge_when_pipeline_succeeds")]
|
||||
public bool MergeWhenPipelineSucceeds { get; set; }
|
||||
|
||||
[JsonProperty("sha")]
|
||||
public string Sha { get; set; }
|
||||
|
||||
[JsonProperty("project_id")]
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
[JsonProperty("should_remove_source_branch")]
|
||||
public bool? ShouldRemoveSourceBranch { get; set; }
|
||||
|
||||
[JsonProperty("target_project_id")]
|
||||
public int TargetProjectId { get; set; }
|
||||
|
||||
[JsonProperty("state")]
|
||||
public MergeRequestState State { get; set; }
|
||||
|
||||
[JsonProperty("source_project_id")]
|
||||
public int SourceProjectId { get; set; }
|
||||
|
||||
[JsonProperty("closed_at")]
|
||||
public DateTime? ClosedAt { get; set; }
|
||||
|
||||
[JsonProperty("closed_by")]
|
||||
public ClosedBy ClosedBy { get; set; }
|
||||
|
||||
[JsonProperty("target_branch")]
|
||||
public string TargetBranch { get; set; }
|
||||
|
||||
[JsonProperty("upvotes")]
|
||||
public int Upvotes { get; set; }
|
||||
|
||||
[JsonProperty("web_url")]
|
||||
public string WebUrl { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("user_notes_count")]
|
||||
public int UserNotesCount { get; set; }
|
||||
|
||||
[JsonProperty("work_in_progress")]
|
||||
public bool WorkInProgress { get; set; }
|
||||
|
||||
[JsonProperty("time_stats")]
|
||||
public MergeRequestTimeStatistic TimeStats { get; set; }
|
||||
|
||||
[JsonProperty("pipeline")]
|
||||
public Pipeline Pipeline { get; set; }
|
||||
|
||||
[JsonProperty("merged_by")]
|
||||
public Assignee MergedBy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using Approve.Checker.Gitlab.Dto;
|
||||
using GitLabApiClient.Models.Job.Responses;
|
||||
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||
using Newtonsoft.Json;
|
||||
@@ -54,7 +55,7 @@ public class GitlabCustomClient : IGitlabCustomClient
|
||||
return responseObj!;
|
||||
}
|
||||
|
||||
public async Task<MergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch)
|
||||
public async Task<CustomMergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, $"{_url}/api/v4/merge_requests?target_branch={targetBranch}&scope=all&per_page=1000");
|
||||
request.Headers.Add("PRIVATE-TOKEN", _token);
|
||||
@@ -62,7 +63,7 @@ public class GitlabCustomClient : IGitlabCustomClient
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var responseStr = await response.Content.ReadAsStringAsync();
|
||||
var responseObj = JsonConvert.DeserializeObject<MergeRequest[]>(responseStr)!;
|
||||
var responseObj = JsonConvert.DeserializeObject<CustomMergeRequest[]>(responseStr)!;
|
||||
return responseObj;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GitLabApiClient.Models.Job.Responses;
|
||||
using Approve.Checker.Gitlab.Dto;
|
||||
using GitLabApiClient.Models.Job.Responses;
|
||||
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto;
|
||||
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto.ApprovalState;
|
||||
@@ -10,7 +11,7 @@ public interface IGitlabCustomClient
|
||||
Task<Reviewers[]> GetReviewers(string projectId, int Iid);
|
||||
Task<ApprovalStateResponse> GetApprovals(string projectId, int Iid);
|
||||
Task<ApprovalStateResponse> GetDiscussions(string projectId, int Iid);
|
||||
Task<MergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch);
|
||||
Task<CustomMergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch);
|
||||
Task<Job[]> GetPipelineTriggers(string projectId, int pipelineId);
|
||||
Task RestartJob(string projectId, int failedJobId);
|
||||
Task<MergeRequest[]> GetMergeRequestsBySourceBranch(string targetBranch);
|
||||
|
||||
Reference in New Issue
Block a user