Ejemplo n.º 1
0
        protected void FillSource(ArticleItemYaml yaml, XElement node)
        {
            var location = node.NullableElement("location");

            if (!location.IsNull())
            {
                string headerPath         = location.NullableAttribute("file").NullableValue();
                string headerStartlineStr = location.NullableAttribute("line").NullableValue();
                int    headerStartline    = ParseStartline(headerStartlineStr);
                string bodyPath           = location.NullableAttribute("bodyfile").NullableValue();
                string bodyStartlineStr   = location.NullableAttribute("bodystart").NullableValue();
                int    bodyStartline      = ParseStartline(bodyStartlineStr);
                string path         = bodyPath ?? headerPath;
                int    startLine    = path == bodyPath ? bodyStartline : headerStartline;
                var    info         = GitUtility.GetGitInfo(path);
                string relativePath = GetRelativePath(path, info?.LocalWorkingDirectory);
                yaml.Source = new SourceDetail
                {
                    Remote = new GitDetail {
                        RemoteRepositoryUrl = info?.RemoteRepoUrl, RemoteBranch = info?.RemoteBranch, RelativePath = relativePath
                    },
                    Path      = relativePath,
                    StartLine = startLine,
                };
            }
        }