Edits for /revision.

This commit is contained in:
Irina Tiulneva 2021-06-18 13:03:03 +03:00
parent 543e774673
commit 4e69540d14
2 changed files with 43 additions and 59 deletions

View File

@ -34,12 +34,6 @@ public class DebugInfo
try
{
basePath = HttpContext.Current.Server.MapPath("~/");
var ChangeLogFilePath = Path.Combine(basePath, DataName);
var ResultNameFilePath = Path.Combine(basePath, ResultName);
if (File.Exists(ResultNameFilePath) && File.Exists(ChangeLogFilePath))
{
File.Delete(ResultNameFilePath);
}
DebugString = GetStaticDebugString();
isInit = true;
}
@ -55,74 +49,64 @@ public class DebugInfo
var ChangeLogFilePath = Path.Combine(basePath, DataName);
var ResultNameFilePath = Path.Combine(basePath, ResultName);
if (File.Exists(ResultNameFilePath))
if (File.Exists(ResultNameFilePath) && !File.Exists(ChangeLogFilePath))
{
if (File.Exists(ChangeLogFilePath))
{
File.Delete(ChangeLogFilePath);
}
if (File.ReadAllText(ResultNameFilePath, Encoding.Default) != "")
{
return File.ReadAllText(ResultNameFilePath);
}
}
if (File.Exists(ChangeLogFilePath))
var ChangeLogPatternFilePath = Path.Combine(basePath, TemplateName);
var xmlLog = new XmlDocument();
xmlLog.Load(ChangeLogFilePath);
var logs = xmlLog.SelectNodes("//lastBuiltRevision");
if (logs == null) return "";
var nodes = logs.Cast<XmlNode>().ToList();
try
{
var ChangeLogPatternFilePath = Path.Combine(basePath, TemplateName);
var fileContent = File.ReadAllText(ChangeLogPatternFilePath, Encoding.Default);
var xmlLog = new XmlDocument();
xmlLog.Load(ChangeLogFilePath);
var lastCommitIDNode = nodes.LastOrDefault();
var branchNameNode = lastCommitIDNode;
var logs = xmlLog.SelectNodes("//lastBuiltRevision");
if (logs == null) return "";
var nodes = logs.Cast<XmlNode>().ToList();
try
if (lastCommitIDNode != null)
{
var fileContent = File.ReadAllText(ChangeLogPatternFilePath, Encoding.Default);
var lastCommitIDNode = nodes.LastOrDefault();
var branchNameNode = lastCommitIDNode;
if (lastCommitIDNode != null)
var lastCommitID = lastCommitIDNode.SelectSingleNode("SHA1");
if (lastCommitID != null)
{
var lastCommitID = lastCommitIDNode.SelectSingleNode("SHA1");
if (lastCommitID != null)
{
fileContent = fileContent.Replace("{RevisionLast}", lastCommitID.InnerText);
}
fileContent = fileContent.Replace("{RevisionLast}", lastCommitID.InnerText);
}
else
{
fileContent = fileContent.Replace("{RevisionLast}", "");
}
if (branchNameNode != null)
{
var branchName = branchNameNode.SelectSingleNode(".//name");
if (branchName != null)
{
fileContent = fileContent.Replace("{BranchName}", branchName.InnerText);
}
}
else
{
fileContent = fileContent.Replace("{BranchName}", "");
}
File.WriteAllText(ResultNameFilePath, fileContent);
if (File.Exists(ChangeLogFilePath))
{
File.Delete(ChangeLogFilePath);
}
return fileContent;
}
catch (Exception e)
else
{
LogManager.GetLogger("ASC.DebugInfo").Error("DebugInfo", e);
fileContent = fileContent.Replace("{RevisionLast}", "");
}
if (branchNameNode != null)
{
var branchName = branchNameNode.SelectSingleNode(".//name");
if (branchName != null)
{
fileContent = fileContent.Replace("{BranchName}", branchName.InnerText);
}
}
else
{
fileContent = fileContent.Replace("{BranchName}", "");
}
File.WriteAllText(ResultNameFilePath, fileContent);
File.Delete(ChangeLogFilePath);
return fileContent;
}
catch (Exception e)
{
LogManager.GetLogger("ASC.DebugInfo").Error("DebugInfo", e);
}
return "";
}

View File

@ -15,7 +15,7 @@ namespace TeamLab.HttpHandlers
public void ProcessRequest(HttpContext context)
{
var DebugString = DebugInfo.DebugString;
string result;
string result = "result's empty";
if (!String.IsNullOrEmpty(DebugString))
{
result = DebugString;