fix: use single output format for alt list and alr list -I
	
		
			
	
		
	
	
				
					
				
			This commit is contained in:
		| @@ -22,6 +22,7 @@ package overrides | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"regexp" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"golang.org/x/exp/slices" | ||||
| @@ -182,3 +183,18 @@ func ReleasePlatformSpecific(release int, info *distro.OSRelease) string { | ||||
|  | ||||
| 	return fmt.Sprintf("%d", release) | ||||
| } | ||||
|  | ||||
| func ParseReleasePlatformSpecific(s string, info *distro.OSRelease) (int, error) { | ||||
| 	if info.ID == "altlinux" { | ||||
| 		if strings.HasPrefix(s, "alt") { | ||||
| 			return strconv.Atoi(s[3:]) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if info.ID == "fedora" || slices.Contains(info.Like, "fedora") { | ||||
| 		parts := strings.SplitN(s, ".", 2) | ||||
| 		return strconv.Atoi(parts[0]) | ||||
| 	} | ||||
|  | ||||
| 	return strconv.Atoi(s) | ||||
| } | ||||
|   | ||||
| @@ -233,5 +233,8 @@ func TestReleasePlatformSpecific(t *testing.T) { | ||||
| 		}, | ||||
| 	} { | ||||
| 		assert.Equal(t, tc.expected, overrides.ReleasePlatformSpecific(1, tc.info)) | ||||
| 		release, err := overrides.ParseReleasePlatformSpecific(tc.expected, tc.info) | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.Equal(t, 1, release) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user