apparently commit hashes in filenames and in log could have different prefix length

This commit is contained in:
13xforever
2018-07-20 14:26:11 +05:00
committed by Roberto Anić Banić
parent 311e9dd683
commit a4c24e516e

View File

@@ -212,10 +212,22 @@ namespace CompatBot.Utils.ResultFormatters
return null;
var latestBuildInfo = BuildInfoInUpdate.Match(link.ToLowerInvariant());
if (!latestBuildInfo.Success || buildInfo.Groups["commit"].Value == latestBuildInfo.Groups["commit"].Value)
if (!latestBuildInfo.Success || SameCommits(buildInfo.Groups["commit"].Value, latestBuildInfo.Groups["commit"].Value))
return null;
return updateInfo;
}
private static bool SameCommits(string commitA, string CommitB)
{
if (string.IsNullOrEmpty(commitA) && string.IsNullOrEmpty(CommitB))
return true;
if (string.IsNullOrEmpty(commitA) || string.IsNullOrEmpty(CommitB))
return false;
var len = Math.Min(commitA.Length, CommitB.Length);
return commitA.Substring(0, len) == CommitB.Substring(0, len);
}
}
}