check if custom mirror is a git URL + remove a todo

pull/30/head
Miepee 5 years ago
parent 3252d23ed5
commit 7741bbd1ef

@ -19,7 +19,7 @@ namespace AM2RLauncher.Language {
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Text {
@ -366,6 +366,15 @@ namespace AM2RLauncher.Language {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die $NAME is an invalid git URL! ähnelt.
/// </summary>
public static string InvalidGitURL {
get {
return ResourceManager.GetString("InvalidGitURL", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Java not found! Cannot generate an APK without a Java installation. Please make sure that Java is installed and added to PATH. ähnelt.
/// </summary>

@ -219,6 +219,9 @@
<data name="InternetConnectionDrop" xml:space="preserve">
<value>Couldn't establish an internet connection! Try again later!</value>
</data>
<data name="InvalidGitURL" xml:space="preserve">
<value>$NAME is an invalid git URL!</value>
</data>
<data name="JavaNotFound" xml:space="preserve">
<value>Java not found! Cannot generate an APK without a Java installation. Please make sure that Java is installed and added to PATH.</value>
</data>

@ -846,8 +846,18 @@ namespace AM2RLauncher
/// </summary>
private void CustomMirrorTextBoxLostFocus(object sender, EventArgs e)
{
// Check first, if the text is a valid git repo
Regex gitURLRegex = new Regex("https://.*\\.git");
string mirrorText = customMirrorTextBox.Text;
if (!gitURLRegex.IsMatch(mirrorText))
{
log.Info("User used " + mirrorText + " as a custom Mirror, didn't pass git validation test.");
//TODO: Localize these
MessageBox.Show(Language.Text.InvalidGitURL.Replace("$NAME", mirrorText), Language.Text.ErrorWindowTitle, MessageBoxType.Error);
return;
}
currentMirror = customMirrorTextBox.Text;
currentMirror = mirrorText;
CrossPlatformOperations.WriteToConfig("CustomMirrorText", currentMirror);
log.Info("Overwriting mirror in gitconfig.");
@ -856,7 +866,6 @@ namespace AM2RLauncher
string gitConfigPath = CrossPlatformOperations.CURRENTPATH + "/PatchData/.git/config";
if (!File.Exists(gitConfigPath)) return;
string gitConfig = File.ReadAllText(gitConfigPath);
Regex gitURLRegex = new Regex("https://.*\\.git");
Match match = gitURLRegex.Match(gitConfig);
gitConfig = gitConfig.Replace(match.Value, currentMirror);
File.WriteAllText(gitConfigPath, gitConfig);

@ -140,7 +140,6 @@ namespace AM2RLauncher
log.Info("Set Launcher CWD to " + Environment.CurrentDirectory);
// But log actual folder location nonetheless
// TODO: test if this logs correctly on windows now
log.Info("Actual Launcher location: " + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory));
// Set the language to what User wanted or choose local language
@ -150,7 +149,6 @@ namespace AM2RLauncher
log.Info("Language has been set to: " + Thread.CurrentThread.CurrentUICulture.EnglishName);
#region VARIABLE INITIALIZATION
log.Info("Beginning UI initialization...");

Loading…
Cancel
Save