Exemple #1
0
        public static GitSourceTool SetUpRealGitSourceTool(Logger logger = null, PerformanceConfiguration pc = null)
        {
            var vsTsTool = SetUpRealVsTsTool();

            var output = new GitSourceTool(vsTsTool, logger, pc ?? SetUpPerformanceConfiguration());

            return(output);
        }
Exemple #2
0
        private static GitSourceTool SetUpClient()
        {
            var personalAccessToken = AuthenticationHelper.GetPersonalAccessToken();

            var tool = new VsTsTool(AppSettings.ServerUri, personalAccessToken, AppSettings.Project);

            var client = new GitSourceTool(tool);

            return(client);
        }
Exemple #3
0
        public static GitSourceTool SetUpFakeGitSourceTool(Logger logger = null, PerformanceConfiguration pc = null)
        {
            if (pc == null)
            {
                pc = SetUpPerformanceConfiguration();
            }

            var vsTsTool = SetUpFakeVsTsTool(pc);

            var sourceTool = new GitSourceTool(vsTsTool, logger, pc);

            return(sourceTool);
        }
Exemple #4
0
        private static void GetRepositoryInformation(
            GitSourceTool client,
            out SourceInformation[] items,
            out SourceInformation[] files)
        {
            var searchInformation = new SourceInformation(
                SourceType.TfsGit,
                "/",
                true,
                AppSettings.GitRepository,
                AppSettings.GitBranch);

            WriteOutput("Getting repository content...");

            items = client.GetItems(searchInformation)
                    .Select(x => client.Map(x, AppSettings.GitRepository, AppSettings.GitBranch))
                    .ToArray();

            WriteOutput("Selecting Markdown files...");

            files = items.Where(
                x => !x.IsDirectory && x.SourcePath.EndsWith(".md", StringComparison.CurrentCultureIgnoreCase))     //.Take(50)
                    .ToArray();
        }
Exemple #5
0
        private static IEnumerable <MarkdownMetadata> ParseInformation(
            IEnumerable <SourceInformation> files,
            GitSourceTool client)
        {
            var metadataItems = new ConcurrentBag <MarkdownMetadata>();

            var exceptions = new ConcurrentQueue <Exception>();

            Parallel.ForEach(
                files,
                file =>
            {
                try
                {
                    WriteOutput($"Parsing {file.SourcePath}");

                    var content = client.GetItemContent(file);

                    var metadata = Parser.Parse(content, file);

                    metadataItems.Add(metadata);
                }
                catch (Exception e)
                {
                    exceptions.Enqueue(e);
                }
            }
                );

            if (exceptions.Count > 0)
            {
                throw new AggregateException(exceptions);
            }

            return(metadataItems);
        }