Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26df0e5

Browse files
committed
make autoversion regex match more robust
1 parent588efc0 commit26df0e5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎scripts/release/main.go‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,15 @@ func (r *releaseCommand) autoversionFile(ctx context.Context, file, channel, ver
385385
// Utilize the index where the match was found to replace the correct part. The only
386386
// match group is the version.
387387
ifmatch:=matchRe.FindStringSubmatchIndex(line);match!=nil {
388-
logger.Info(ctx,"updating version number","line_number",i+1,"match",match,"old_version",line[match[2]:match[3]])
389-
lines[i]=line[:match[2]]+version+line[match[3]:]
388+
vg:=matchRe.SubexpIndex("version")
389+
ifvg==-1 {
390+
logger.Error(ctx,"version group not found in match","num_subexp","match",match,matchRe.NumSubexp(),"subexp_names",matchRe.SubexpNames())
391+
returnxerrors.Errorf("bug: version group not found in match")
392+
}
393+
start:=match[vg*2]
394+
end:=match[vg*2+1]
395+
logger.Info(ctx,"updating version number","line_number",i+1,"match_start",start,"match_end",end,"old_version",line[start:end])
396+
lines[i]=line[:start]+version+line[end:]
390397
matchRe=nil
391398
break
392399
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp