mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	 449b2e3117
			
		
	
	449b2e3117
	
	
	
		
			
			Fix `tea releases assets <tag_name>` displayed wrong attachment size. Reviewed-on: https://gitea.com/gitea/tea/pulls/787 Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			613 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			613 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2024 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package print
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 
 | |
| 	"code.gitea.io/sdk/gitea"
 | |
| )
 | |
| 
 | |
| func formatByteSize(size int64) string {
 | |
| 	if size < 1024 {
 | |
| 		return fmt.Sprintf("%d B", size)
 | |
| 	}
 | |
| 	return formatSize(size / 1024)
 | |
| }
 | |
| 
 | |
| // ReleaseAttachmentsList prints a listing of release attachments
 | |
| func ReleaseAttachmentsList(attachments []*gitea.Attachment, output string) {
 | |
| 	t := tableWithHeader(
 | |
| 		"Name",
 | |
| 		"Size",
 | |
| 	)
 | |
| 
 | |
| 	for _, attachment := range attachments {
 | |
| 		t.addRow(
 | |
| 			attachment.Name,
 | |
| 			formatByteSize(attachment.Size),
 | |
| 		)
 | |
| 	}
 | |
| 
 | |
| 	t.print(output)
 | |
| }
 |