You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							e3f494fdc9
						
					
				
				
					commit
					a726a29d70
				
			| @@ -63,8 +63,9 @@ type ReleaserURLTemplater interface { | ||||
|  | ||||
| // RepoFile is a file to be created. | ||||
| type RepoFile struct { | ||||
| 	Content []byte | ||||
| 	Path    string | ||||
| 	Content    []byte | ||||
| 	Path       string | ||||
| 	Identifier string // for the use of the caller. | ||||
| } | ||||
|  | ||||
| // FileCreator can create the given file to some code repository. | ||||
|   | ||||
| @@ -26,7 +26,7 @@ type Mock struct { | ||||
| 	CreatedFile          bool | ||||
| 	Content              string | ||||
| 	Path                 string | ||||
| 	Message              string | ||||
| 	Messages             []string | ||||
| 	FailToCreateRelease  bool | ||||
| 	FailToUpload         bool | ||||
| 	CreatedRelease       bool | ||||
| @@ -89,7 +89,7 @@ func (c *Mock) CreateFile(_ *context.Context, _ config.CommitAuthor, _ Repo, con | ||||
| 	c.CreatedFile = true | ||||
| 	c.Content = string(content) | ||||
| 	c.Path = path | ||||
| 	c.Message = msg | ||||
| 	c.Messages = append(c.Messages, msg) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -335,8 +335,9 @@ func doPublish(ctx *context.Context, cl client.Client, wingets []*artifact.Artif | ||||
| 			return err | ||||
| 		} | ||||
| 		files = append(files, client.RepoFile{ | ||||
| 			Content: content, | ||||
| 			Path:    filepath.Join(winget.Path, pkg.Name), | ||||
| 			Content:    content, | ||||
| 			Path:       filepath.Join(winget.Path, pkg.Name), | ||||
| 			Identifier: repoFileID(pkg.Type), | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| @@ -351,7 +352,14 @@ func doPublish(ctx *context.Context, cl client.Client, wingets []*artifact.Artif | ||||
| 	} | ||||
|  | ||||
| 	for _, file := range files { | ||||
| 		if err := cl.CreateFile(ctx, author, repo, file.Content, file.Path, msg); err != nil { | ||||
| 		if err := cl.CreateFile( | ||||
| 			ctx, | ||||
| 			author, | ||||
| 			repo, | ||||
| 			file.Content, | ||||
| 			file.Path, | ||||
| 			msg+": add "+file.Identifier, | ||||
| 		); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
| @@ -398,3 +406,17 @@ func extFor(tp artifact.Type) string { | ||||
| 		return "" | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func repoFileID(tp artifact.Type) string { | ||||
| 	switch tp { | ||||
| 	case artifact.WingetVersion: | ||||
| 		return "version" | ||||
| 	case artifact.WingetInstaller: | ||||
| 		return "installer" | ||||
| 	case artifact.WingetDefaultLocale: | ||||
| 		return "locale" | ||||
| 	default: | ||||
| 		// should never happen | ||||
| 		return "" | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -656,7 +656,21 @@ func TestRunPipe(t *testing.T) { | ||||
| 			require.NoError(t, pipe.publishAll(ctx, client)) | ||||
| 			require.True(t, client.CreatedFile) | ||||
|  | ||||
| 			require.Regexp(t, "New version: \\w+\\.[\\w-]+ 1.2.1", client.Message) | ||||
| 			require.Len(t, client.Messages, 3) | ||||
| 			expected := map[string]bool{ | ||||
| 				"locale":    false, | ||||
| 				"version":   false, | ||||
| 				"installer": false, | ||||
| 			} | ||||
| 			for _, msg := range client.Messages { | ||||
| 				require.Regexp(t, "New version: \\w+\\.[\\w-]+ 1.2.1", msg) | ||||
| 				for k, v := range expected { | ||||
| 					if strings.Contains(msg, ": add "+k) { | ||||
| 						require.False(t, v, "multiple commits for "+k) | ||||
| 						expected[k] = true | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			require.NotEmpty(t, client.Path) | ||||
| 			if tt.expectPath != "" { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user