Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化命名 #1

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DotNetGitLabWebHook/Business/Check/FileChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public FileChecker(RepoManager repoManager)

public void Check(GitLabMergeRequest gitLabMergeRequest)
{
var repositoryUrl = gitLabMergeRequest.RawProperty.repository.url;
var repoFolder = RepoManager.GetRepo(repositoryUrl, gitLabMergeRequest.RawProperty.repository.name);
var repositoryUrl = gitLabMergeRequest.RawProperty.Repository.Url;
var repoFolder = RepoManager.GetRepo(repositoryUrl, gitLabMergeRequest.RawProperty.Repository.Name);

var git = new Git(repoFolder);

Expand Down
3 changes: 1 addition & 2 deletions DotNetGitLabWebHook/Business/GitLabMRCheckerFlow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNetGitLabWebHook.Model;
using DotNetGitLabWebHookToMatterMost.Business.Check;
using DotNetGitLabWebHookToMatterMost.Business.Check;
using DotNetGitLabWebHookToMatterMost.Model;
using Microsoft.Extensions.Configuration;

Expand Down
10 changes: 5 additions & 5 deletions DotNetGitLabWebHook/Business/Notify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Notify(IConfiguration configuration)
public IConfiguration Configuration { get; }
public void NotifyMatterMost(GitLabMergeRequest gitLabMergeRequest)
{
var state = gitLabMergeRequest.RawProperty.object_attributes.state;
var state = gitLabMergeRequest.RawProperty.ObjectAttributes.State;

string text = "";

Expand All @@ -28,7 +28,7 @@ public void NotifyMatterMost(GitLabMergeRequest gitLabMergeRequest)
}
else if (state == "merged")
{
var username = gitLabMergeRequest.RawProperty.user.username;
var username = gitLabMergeRequest.RawProperty.User.Username;
text = $"恭喜@{username} [{gitLabMergeRequest.CommonProperty.Title}]({gitLabMergeRequest.CommonProperty.MergeRequestUrl}) 已经合并";
}
else
Expand All @@ -37,11 +37,11 @@ public void NotifyMatterMost(GitLabMergeRequest gitLabMergeRequest)
//var action = gitLabMergeRequest.RawProperty.object_attributes.action;
// action 有三个值 update open reopen

var assignees = gitLabMergeRequest.RawProperty.assignees;
var assigneeList = new List<string> { gitLabMergeRequest.RawProperty.object_attributes.assignee?.username };
var assignees = gitLabMergeRequest.RawProperty.Assignees;
var assigneeList = new List<string> { gitLabMergeRequest.RawProperty.ObjectAttributes.Assignee?.Username };
if (assignees != null)
{
assigneeList.AddRange(assignees.Select(temp => temp.username));
assigneeList.AddRange(assignees.Select(temp => temp.Username));
}

var assigneeUsername = string.Join(' ',
Expand Down
23 changes: 11 additions & 12 deletions DotNetGitLabWebHook/Controllers/GitLabWebHookController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNetGitLabWebHook.Model;
using DotNetGitLabWebHookToMatterMost.Business;
using DotNetGitLabWebHookToMatterMost.Business;
using DotNetGitLabWebHookToMatterMost.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -31,24 +30,24 @@ public IActionResult MergeRequest(object obj)
var rootobject =
JsonConvert.DeserializeObject<GitLabMergeRequest.Rootobject>(str);

if (rootobject.object_kind == "merge_request")
if (rootobject.ObjectKind == "merge_request")
{
var objectAttributes = rootobject.object_attributes;
var objectAttributes = rootobject.ObjectAttributes;

var sourceGitSshUrl = objectAttributes.source.git_ssh_url;
var sourceBranch = objectAttributes.source_branch;
var sourceGitSshUrl = objectAttributes.Source.GitSshUrl;
var sourceBranch = objectAttributes.SourceBranch;

// 最后提交号
var lastCommitId = objectAttributes.last_commit.id;
var lastCommitId = objectAttributes.LastCommit.Id;

var targetGitSshUrl = objectAttributes.target.git_ssh_url;
var targetBranch = objectAttributes.target_branch;
var targetGitSshUrl = objectAttributes.Target.GitSshUrl;
var targetBranch = objectAttributes.TargetBranch;

// MR 标题
var title = objectAttributes.title;
var title = objectAttributes.Title;

var username = rootobject.user.username;
var mergeRequestUrl = objectAttributes.url;
var username = rootobject.User.Username;
var mergeRequestUrl = objectAttributes.Url;

var gitLabMergeRequest = new GitLabMergeRequest
{
Expand Down
Loading