code_style: rewrite Commands.QueryTags.ParseLine

This commit is contained in:
leo 2024-10-15 16:41:25 +08:00
parent 5bad969bb7
commit b6468e310b
No known key found for this signature in database

View file

@ -32,25 +32,14 @@ namespace SourceGit.Commands
private Models.Tag ParseLine(string line)
{
var subs = line.Split('\0', StringSplitOptions.RemoveEmptyEntries);
if (subs.Length == 2)
{
return new Models.Tag()
{
Name = subs[0].Substring(10),
SHA = subs[1],
};
}
else if (subs.Length == 3)
{
return new Models.Tag()
{
Name = subs[0].Substring(10),
SHA = subs[2],
};
}
var subs = line.Split('\0');
if (subs.Length != 3)
return null;
var tag = new Models.Tag();
tag.Name = subs[0].Substring(10);
tag.SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2];
return tag;
}
}
}