예제 #1
0
 public GithubService(TargetProject targetProject)
 {
     _accessToken    = SecretService.GetGithubSecrets().AccessToken;
     _owner          = targetProject.OrganizationName;
     _repositoryName = targetProject.RepositoryName;
     _bugLabel       = targetProject.BugLabel;
     _client         = new RestClient(BaseUrl);
 }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Repository Analyzer");
            Console.WriteLine("Select target project");

            TargetProject[] targetProjects = TargetProject.GetTargetProjects();
            for (int i = 0; i < targetProjects.Length; i++)
            {
                Console.WriteLine($@"[{(char)('A' + i) }]: {targetProjects[i].OrganizationName}/{targetProjects[i].RepositoryName}");
            }

            Console.Write("Please enter project #: ");
            var input  = Console.ReadKey().KeyChar;
            int choice = char.ToUpper(input) - 65;

            Console.WriteLine();

            TargetProject targetProject = targetProjects[choice];

            IIssueTrackerService issueTrackerService;

            if (targetProject.RepositoryName == "knowNow")
            {
                issueTrackerService = new TfsService($@"{RepositoriesFolder}/{targetProject.RepositoryName}");;
            }
            else
            {
                issueTrackerService = new GithubService(targetProject);
            }

            string solutionFile = $@"{RepositoriesFolder}/{targetProject.RepositoryName}/{targetProject.SolutionFileLocation}";

            _repository   = targetProject.RepositoryName;
            _shellService = new ShellService($@"{RepositoriesFolder}/{_repository}");
//            _shellService.CheckoutCommit();
            var hash = _shellService.GetHeadHash();
            RepositoryWithMetrics      repositoryWithMetrics = new RepositoryWithMetrics();
            MetricRunner               runner = new MetricRunner(solutionFile);
            SolutionVersionWithMetrics solutionVersionWithMetrics = runner.GetSolutionVersionWithMetrics().Result;

            repositoryWithMetrics.AddVersion("HEAD", solutionVersionWithMetrics);

            List <FaultyVersion>     faultyVersions     = issueTrackerService.GetFaultyVersions();
            Dictionary <string, int> bugAmountInClasses = GetBugAmountInClasses(faultyVersions);

            List <OutputRow> output = GetOutput(solutionVersionWithMetrics.ClassesWithMetrics, bugAmountInClasses);

            OutputCsv(output, $@"C:\Users\BartZ\code-analysis-results\{targetProject.OrganizationName}_{_repository}_{hash}_complete.csv");

            Console.ReadKey();
        }