Beispiel #1
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));
        }
        public IEnumerable <PipelineData> GetPipelines()
        {
            var repository = _gitLabCLient.GetRepository(_project.Id);

            var pipelines = repository.Pipelines.All();

            return(pipelines);
        }
Beispiel #3
0
        public GitLabAuditEnvironment(EventHandler <EnvironmentEventArgs> message_handler, string api_token, string host_url, string project_name, string repository_branch, LocalEnvironment host_environment)
            : base(message_handler, new OperatingSystem(PlatformID.Unix, new Version(0, 0)), host_environment)
        {
            try
            {
                GitLabClient = new GitLabClient(host_url, api_token);
                IEnumerable <Project> projects = GitLabClient.Projects.Accessible().Result;
                Project = projects.Where(p => p.PathWithNamespace == project_name).FirstOrDefault();
                if (Project == null)
                {
                    host_environment.Error("Could not find project {0}.", project_name);
                    RepositoryInitialised = false;
                    return;
                }
                Repository = GitLabClient.GetRepository(Project.Id);
                if (Repository == null)
                {
                    host_environment.Error("Could not get repository for project {0}.", project_name);
                    RepositoryInitialised = false;
                    return;
                }
            }
            catch (AggregateException ae)
            {
                host_environment.Error(ae, "Error getting repository for project {0} from {1}.", project_name, host_url);
                RepositoryInitialised = false;
                return;
            }
            catch (Exception e)
            {
                host_environment.Error(e, "Error getting repository for project {0} from {1}.", project_name, host_url);
                RepositoryInitialised = false;
                return;
            }

            try
            {
                RepositoryBranch = Repository.Branches.All().Result.Where(b => b.Name == repository_branch).FirstOrDefault();
            }
            catch (AggregateException ae)
            {
                host_environment.Error(ae, "Error getting branch {0}.", repository_branch);
                RepositoryInitialised = false;
                return;
            }
            catch (Exception e)
            {
                host_environment.Error(e, "Error getting branch {0}.", repository_branch);
                RepositoryInitialised = false;
                return;
            }

            this.RepositoryInitialised = true;
        }
Beispiel #4
0
        public IEnumerable <MergeRequestFileData> GetCommitChanges(Project project, Sha1 from, Sha1 to)
        {
            var repoClient  = client.GetRepository(project.Id);
            var compareInfo = repoClient.Compare(from, to);
            var files       = compareInfo.Diff.Select(x =>
                                                      new MergeRequestFileData()
            {
                AMode     = x.AMode,
                BMode     = x.BMode,
                Diff      = x.Difference,
                IsDeleted = x.IsDeletedFile,
                IsNew     = x.IsNewFile,
                IsRenamed = x.IsRenamedFile,
                NewPath   = Uri.UnescapeDataString(x.NewPath),
                OldPath   = Uri.UnescapeDataString(x.OldPath)
            });

            return(files);
        }