Skip to content

Commit

Permalink
Ignore package revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielrobert committed Mar 25, 2018
1 parent 4a7fe1f commit 9f94a33
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
6 changes: 4 additions & 2 deletions actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func increment(c *cli.Context) error {
}

setVersion(file, newVersion)
fmt.Println(fmt.Sprintf("%v: New version: %v (%v)", file.Version, newVersion, file.Path))
updatedManifest := findManifests(file.Path)[0]
fmt.Println(fmt.Sprintf("%v: New version: %v (%v)", file.Version, updatedManifest.Version, file.Path))
}
return nil
}
Expand Down Expand Up @@ -94,7 +95,8 @@ func set(c *cli.Context) error {
// execute version update
for _, file := range allFiles {
setVersion(file, newVersion)
fmt.Println(fmt.Sprintf("%v: New version: %v (%v)", file.Version, newVersion, file.Path))
updatedManifest := findManifests(file.Path)[0]
fmt.Println(fmt.Sprintf("%v: New version: %v (%v)", file.Version, updatedManifest.Version, file.Path))
}
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions uwp_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func Test_isUWPPackage(t *testing.T) {

func Test_getUWPPackageInfo(t *testing.T) {
currentVersion := getUWPPackageInfo(uwpFilePath)
if currentVersion.Version != "1.0.1" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion.Version, "1.0.1")
if currentVersion.Version != "1.0.1.0" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion.Version, "1.0.1.0")
}
if currentVersion.Name != "xavtool" {
t.Errorf("name mismatch; actual %v, expected %v", currentVersion.Name, "xavtool")
Expand All @@ -44,14 +44,14 @@ func Test_getUWPPackageInfo(t *testing.T) {

func Test_changeUWPPackageVersion(t *testing.T) {
currentVersion := getUWPPackageInfo(uwpFilePath)
if currentVersion.Version != "1.0.1" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion, "1.0.1")
if currentVersion.Version != "1.0.1.0" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion, "1.0.1.0")
}

changeUWPPackageVersion(currentVersion, "1.0.2")
currentVersion = getUWPPackageInfo(uwpFilePath)
if currentVersion.Version != "1.0.2" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion, "1.0.2")
if currentVersion.Version != "1.0.2.0" {
t.Errorf("version mismatch; actual %v, expected %v", currentVersion, "1.0.2.0")
}

// some kind of rollback
Expand All @@ -61,8 +61,8 @@ func Test_changeUWPPackageVersion(t *testing.T) {
func Test_applyVersionToUWPXML(t *testing.T) {
processedBytes := applyVersionToUWPXML(uwpSeed, "1.0.2")
xml, _ := readUWPData(processedBytes)
if xml.Identity.Version != "1.0.2" {
t.Errorf("VersionName mismatch; expected %v, got %v", "1.0.2", xml.Identity.Version)
if xml.Identity.Version != "1.0.2.0" {
t.Errorf("VersionName mismatch; expected %v, got %v", "1.0.2.0", xml.Identity.Version)
}
}

Expand All @@ -77,7 +77,7 @@ func Test_readUWPData(t *testing.T) {
shouldError bool
}{
{"invalid bytes", args{invalidUWPSeed}, "", true},
{"valid file", args{readFile("test/Package.appxmanifest")}, "1.0.1", false},
{"valid file", args{readFile("test/Package.appxmanifest")}, "1.0.1.0", false},
{"valid bytes", args{uwpSeed}, "1.0.1", false},
}
for _, tt := range tests {
Expand Down
6 changes: 6 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"strconv"
"strings"

"github.com/Masterminds/semver"
)
Expand All @@ -26,6 +27,11 @@ func incrementPatch(version string) string {
}

func parse(version string) *semver.Version {
if !isVersion(version) {
segments := strings.Split(version, ".")
version = fmt.Sprintf("%v.%v.%v", segments[0], segments[1], segments[2])
}

parsedVersion, err := semver.NewVersion(version)
check(err)
return parsedVersion
Expand Down
8 changes: 8 additions & 0 deletions version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"testing"

"github.com/stretchr/testify/assert"
)

func Test_incrementMajor(t *testing.T) {
Expand Down Expand Up @@ -70,6 +72,12 @@ func Test_incrementPatch(t *testing.T) {
}
}

func Test_parse(t *testing.T) {
t.Run("parse version with revision", func(t *testing.T) {
assert.NotPanics(t, func() { parse("0.0.0.0") })
})
}

func Test_isVersion(t *testing.T) {
type args struct {
version string
Expand Down

0 comments on commit 9f94a33

Please sign in to comment.