From b6468e310b7673945bc70cf4cbd3611bb592571e Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 15 Oct 2024 16:41:25 +0800 Subject: [PATCH] code_style: rewrite `Commands.QueryTags.ParseLine` --- src/Commands/QueryTags.cs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/Commands/QueryTags.cs b/src/Commands/QueryTags.cs index 54ff85d6..0547b396 100644 --- a/src/Commands/QueryTags.cs +++ b/src/Commands/QueryTags.cs @@ -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; - 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; } } }