예제 #1
0
 public MergeRequest CreateMergeRequest(Project origin, Project upstream, string title, string description, string user, string sourceBranch, string targetBranch)
 {
     var mergeRequestClient = this.client.GetMergeRequest(origin.Id);
     var mergeRequest = mergeRequestClient.Create(new MergeRequestCreate() {
         Title = title,
         Description = description,
         SourceBranch = sourceBranch,
         TargetBranch = targetBranch,
         TargetProjectId = upstream.Id,
     });
     return mergeRequest;
 }
예제 #2
0
        ProjectCreate CreateProject(out Project created, string name)
        {
            var p = new ProjectCreate {
                Description = "desc",
                ImportUrl = null,
                IssuesEnabled = true,
                MergeRequestsEnabled = true,
                Name = name,
                NamespaceId = null,
                SnippetsEnabled = true,
                VisibilityLevel = VisibilityLevel.Public,
                WallEnabled = true,
                WikiEnabled = true
            };

            created = _projects.Create(p);
            return p;
        }
예제 #3
0
 public void SetUp()
 {
     Project = Config.Connect().Projects.Owned.First(project => project.Name == "mergeme");
     MergeRequestClient = Config.Connect().GetMergeRequest(Project.Id);
 }
예제 #4
0
파일: Program.cs 프로젝트: Xarlot/DXVcs2Git
 static List<MergeRequest> GetMergeRequests(GitLabWrapper gitLabWrapper, string branchName, string userName, Project project) {
     return gitLabWrapper.GetMergeRequests(project, x => x.TargetBranch == branchName).Where(x => x.Assignee?.Name == userName).ToList();
 }
예제 #5
0
파일: Program.cs 프로젝트: Xarlot/DXVcs2Git
        static void ForceSyncBuild(GitLabWrapper gitLabWrapper, MergeRequest mergeRequest, Project targetProject, MergeRequestHookClient hook) {
            var xmlComments = gitLabWrapper.GetComments(mergeRequest).Where(x => IsXml(x.Note));
            var options = xmlComments.Select(x => MergeRequestOptions.ConvertFromString(x.Note)).FirstOrDefault();
            if (options != null && options.ActionType == MergeRequestActionType.sync) {
                var action = (MergeRequestSyncAction)options.Action;
                if (action.PerformTesting) {
                    Log.Message("Check build status before force build.");
                    var commit = gitLabWrapper.GetMergeRequestCommits(mergeRequest).FirstOrDefault();
                    var build = commit != null ? gitLabWrapper.GetBuilds(mergeRequest, commit.Id).FirstOrDefault() : null;
                    var buildStatus = build?.Status ?? BuildStatus.undefined;
                    Log.Message($"Build status = {buildStatus}.");
                    if (buildStatus == BuildStatus.success)
                        ForceBuild(action.SyncTask);
                    return;
                }
                Log.Message("Build forces without checking tests status.");
                ForceBuild(action.SyncTask);
                return;
            }
            string task = FarmIntegrator.FindTask($"{mergeRequest.TargetBranch}@{targetProject.PathWithNamespace}");
            if (!string.IsNullOrEmpty(task)) {
                Log.Message($"Sync task {task} found by heuristic.");
                ForceBuild(task);
                return;
            }

            Log.Message("Merge request can`t be merged because merge request notes has no farm config.");
            Log.Message("");
        }
예제 #6
0
파일: Program.cs 프로젝트: Xarlot/DXVcs2Git
 static MergeRequest CalcMergeRequest(GitLabWrapper gitLabWrapper, BuildHookClient hook, Project project) {
     foreach (var checkProject in gitLabWrapper.GetProjects()) {
         var mergeRequests = gitLabWrapper.GetMergeRequests(checkProject, x => x.SourceProjectId == project.Id);
         var mergeRequest = mergeRequests.FirstOrDefault(x => x.SourceBranch == hook.Branch);
         if (mergeRequest != null)
             return mergeRequest;
     }
     return null;
 }
예제 #7
0
 public void SetUp()
 {
     _project = Config.Connect().Projects.Owned.Single();
     RepositoryClient = Config.Connect().GetRepository(_project.Id);
 }
예제 #8
0
 public ProjectHook CreateProjectHook(Project project, Uri url, bool mergeRequestEvents, bool pushEvents, bool buildEvents)
 {
     var projectClient = client.GetRepository(project.Id);
     var projectHooks = projectClient.ProjectHooks;
     return projectHooks.Create(new ProjectHookUpsert() { MergeRequestsEvents = mergeRequestEvents, PushEvents = pushEvents, BuildEvents = buildEvents, Url = url, EnableSSLVerification = false});
 }
예제 #9
0
 public IEnumerable<ProjectHook> GetProjectHooks(Project project)
 {
     var repository = this.client.GetRepository(project.Id);
     return repository.ProjectHooks.All;
 }
예제 #10
0
 public ProjectHook UpdateProjectHook(Project project, ProjectHook hook, Uri uri, bool mergeRequestEvents, bool pushEvents, bool buildEvents)
 {
     var repository = this.client.GetRepository(project.Id);
     return repository.ProjectHooks.Update(hook.Id, new ProjectHookUpsert() { Url = uri, MergeRequestsEvents = mergeRequestEvents, PushEvents = pushEvents, BuildEvents = buildEvents, EnableSSLVerification = false});
 }
예제 #11
0
 public IEnumerable<MergeRequest> GetMergeRequests(Project project, Func<MergeRequest, bool> mergeRequestsHandler = null)
 {
     mergeRequestsHandler = mergeRequestsHandler ?? (x => true);
     var mergeRequestsClient = client.GetMergeRequest(project.Id);
     return mergeRequestsClient.AllInState(MergeRequestState.opened).Where(x => mergeRequestsHandler(x));
 }
예제 #12
0
 public MergeRequest GetMergeRequest(Project project, int id)
 {
     var mergeRequestsClient = client.GetMergeRequest(project.Id);
     return mergeRequestsClient[id];
 }
예제 #13
0
 public IEnumerable<Branch> GetBranches(Project project)
 {
     var repo = this.client.GetRepository(project.Id);
     var branchesClient = repo.Branches;
     return branchesClient.All;
 }
예제 #14
0
 public Branch GetBranch(Project project, string branch)
 {
     var repo = this.client.GetRepository(project.Id);
     var branchesClient = repo.Branches;
     try {
         return branchesClient[branch];
     }
     catch {
         return branchesClient.All.FirstOrDefault(x => x.Name == branch);
     }
 }
예제 #15
0
 public ProjectHook FindProjectHook(Project project, Func<ProjectHook, bool> projectHookHandler)
 {
     var projectClient = client.GetRepository(project.Id);
     var projectHooks = projectClient.ProjectHooks;
     return projectHooks.All.FirstOrDefault(projectHookHandler);
 }