Ejemplo n.º 1
0
        async Task <RepositoryUpdatesFormatted> IModelValidationService.GetRepositoryUpdates(long repoId, int pullRequestId, OutputFormat outputFormat)
        {
            IEnumerable <PullRequestFile> allFiles = await gitClient.PullRequest.Files(repoId, pullRequestId);

            var repoUpdates = new RepositoryUpdates
            {
                FilesAdded         = new List <string>(),
                FilesModified      = new List <string>(),
                FilesRemoved       = new List <string>(),
                FilesRenamed       = new List <string>(),
                FilesAddedModified = new List <string>(),
                FilesAll           = new List <string>()
            };

            foreach (PullRequestFile file in allFiles)
            {
                if (outputFormat == OutputFormat.space_delimited && file.FileName.Contains(" "))
                {
                    throw new Exception("One of your files includes a space. Consider using a different output format or removing spaces from your filenames. Please submit an issue on this action's GitHub repo.");
                }

                repoUpdates.FilesAll.Add(file.FileName);

                FileChangeStatus fileStatus = (FileChangeStatus)System.Enum.Parse(typeof(FileChangeStatus), file.Status);

                switch (fileStatus)
                {
                case FileChangeStatus.added:
                    repoUpdates.FilesAdded.Add(file.FileName);
                    repoUpdates.FilesAddedModified.Add(file.FileName);
                    break;

                case FileChangeStatus.modified:
                    repoUpdates.FilesModified.Add(file.FileName);
                    repoUpdates.FilesAddedModified.Add(file.FileName);
                    break;

                case FileChangeStatus.removed:
                    repoUpdates.FilesRemoved.Add(file.FileName);
                    break;

                case FileChangeStatus.renamed:
                    repoUpdates.FilesRenamed.Add(file.FileName);
                    break;

                case FileChangeStatus.none:
                    continue;

                default:
                    throw new Exception("Invalid file status");
                }
            }

            var formattedRepoUpdates = FormatRepositoryUpdates(repoUpdates, outputFormat);

            return(formattedRepoUpdates);
        }
Ejemplo n.º 2
0
 public ChangedFile(string relativeFilePath, FileChangeStatus changeStatus, string changesetNumber)
 {
     m_RelativeFilePath = relativeFilePath;
     m_ChangeStatus     = changeStatus;
     m_ChangesetNumber  = changesetNumber;
 }
Ejemplo n.º 3
0
 public ChangedFile(string relativeFilePath, FileChangeStatus changeStatus, string changesetNumber)
 {
     m_RelativeFilePath = relativeFilePath;
     m_ChangeStatus = changeStatus;
     m_ChangesetNumber = changesetNumber;
 }