@@ -175,11 +175,6 @@ func resolveBaseTag(ctx context.Context, repo *repo_model.Repository, gitRepo *g
175175}
176176
177177func buildBaseSelectionForTag (gitRepo * git.Repository , tagName string ) (* baseSelection , error ) {
178- tagName = strings .TrimSpace (tagName )
179- if tagName == "" {
180- return nil , ErrReleaseNotesNoBaseTag {}
181- }
182-
183178 baseCommit , err := gitRepo .GetCommit (tagName )
184179 if err != nil {
185180 return nil , newErrReleaseNotesTagNotFound (tagName )
@@ -192,11 +187,6 @@ func buildBaseSelectionForTag(gitRepo *git.Repository, tagName string) (*baseSel
192187}
193188
194189func autoPreviousReleaseTag (ctx context.Context , repo * repo_model.Repository , tagName string ) (string , error ) {
195- tagName = strings .TrimSpace (tagName )
196- if tagName == "" {
197- return "" , nil
198- }
199-
200190 currentRelease , err := repo_model .GetRelease (ctx , repo .ID , tagName )
201191 switch {
202192 case err == nil :
@@ -210,11 +200,10 @@ func autoPreviousReleaseTag(ctx context.Context, repo *repo_model.Repository, ta
210200 rel , err := repo_model .GetLatestReleaseByRepoID (ctx , repo .ID )
211201 switch {
212202 case err == nil :
213- candidate := strings .TrimSpace (rel .TagName )
214- if candidate == "" || strings .EqualFold (candidate , tagName ) {
203+ if strings .EqualFold (rel .TagName , tagName ) {
215204 return "" , nil
216205 }
217- return candidate , nil
206+ return rel . TagName , nil
218207 case repo_model .IsErrReleaseNotExist (err ):
219208 return "" , nil
220209 default :
@@ -223,7 +212,6 @@ func autoPreviousReleaseTag(ctx context.Context, repo *repo_model.Repository, ta
223212}
224213
225214func findPreviousPublishedReleaseTag (ctx context.Context , repo * repo_model.Repository , current * repo_model.Release ) (string , error ) {
226- target := strings .TrimSpace (current .TagName )
227215 prev , err := repo_model .GetPreviousPublishedRelease (ctx , repo .ID , current )
228216 switch {
229217 case err == nil :
@@ -233,21 +221,13 @@ func findPreviousPublishedReleaseTag(ctx context.Context, repo *repo_model.Repos
233221 return "" , fmt .Errorf ("GetPreviousPublishedRelease: %w" , err )
234222 }
235223
236- candidate := strings .TrimSpace (prev .TagName )
237- if candidate == "" || strings .EqualFold (candidate , target ) {
238- return "" , nil
239- }
240- return candidate , nil
224+ return prev .TagName , nil
241225}
242226
243227func findPreviousTagName (tags []* git.Tag , target string ) (string , bool ) {
244- target = strings .TrimSpace (target )
245228 foundTarget := false
246229 for _ , tag := range tags {
247230 name := strings .TrimSpace (tag .Name )
248- if name == "" {
249- continue
250- }
251231 if strings .EqualFold (name , target ) {
252232 foundTarget = true
253233 continue
@@ -256,11 +236,8 @@ func findPreviousTagName(tags []*git.Tag, target string) (string, bool) {
256236 return name , true
257237 }
258238 }
259- if ! foundTarget && len (tags ) > 0 {
260- name := strings .TrimSpace (tags [0 ].Name )
261- if name != "" {
262- return name , true
263- }
239+ if len (tags ) > 0 {
240+ return strings .TrimSpace (tags [0 ].Name ), true
264241 }
265242 return "" , false
266243}
0 commit comments