Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Remove semver library that caused issues in test-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
achocron committed Oct 31, 2017
1 parent 1770a17 commit 9361c71
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test-tools.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#tool nuget:?package=XamarinComponent
#addin nuget:?package=Cake.Xamarin
#addin nuget:?package=Cake.FileHelpers
#addin nuget:?package=Cake.SemVer
#addin nuget:?package=Newtonsoft.Json

using System;
Expand Down Expand Up @@ -185,7 +184,7 @@ Task("IncreaseIosVersion").Does(()=>
var openTag = "<string>";
var closeTag = "</string>";
var currentVersion = match.Substring(match.IndexOf(openTag) + openTag.Length, match.IndexOf(closeTag) - match.IndexOf(openTag) - openTag.Length);
var newVersion = IncrementSemVer(currentVersion);
var newVersion = IncrementPatch(currentVersion);
var newBundleVersionString = "<key>CFBundleVersion</key>\n\t<string>" + newVersion + "</string>";
ReplaceRegexInFiles(infoPlistLocation, bundleVersionPattern, newBundleVersionString);
Information("iOS Version increased to " + newVersion);
Expand Down Expand Up @@ -213,7 +212,7 @@ Task("IncreaseAndroidVersion").Does(()=>
{
versionName = versionName.Substring(0, versionName.IndexOf(suffix));
}
var newVersionName = IncrementSemVer(versionName);
var newVersionName = IncrementPatch(versionName);
XmlPoke(manifestLocation, "manifest/@android:versionName", newVersionName, pokeSettings);
Information("Android version name changed to " + newVersionName + ", version code increased to " + newVersionCode);
});
Expand Down Expand Up @@ -335,10 +334,19 @@ void AttachJsonPayload(HttpWebRequest request, JObject json)
}
}

string IncrementSemVer(string semVer)
string IncrementPatch(string semVer)
{
var parsedVersion = ParseSemVer(semVer);
return CreateSemVer(parsedVersion.Major, parsedVersion.Minor, parsedVersion.Patch + 1).ToString();
int patchIdx = 0;
for (int i = semVer.Length - 1; i >= 0; --i)
{
if (semVer[i] == '.')
{
patchIdx = i + 1;
break;
}
}
var newPatch = Convert.ToInt32(semVer.Substring(patchIdx, semVer.Length - patchIdx)) + 1;
return semVer.Substring(0, patchIdx) + newPatch;
}

// Adapted from https://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data/2996904#2996904
Expand Down

0 comments on commit 9361c71

Please sign in to comment.