From 4630560e9e2cf0e5d2af8ef604e2c9be07a62d10 Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Date: Thu, 24 Sep 2015 10:28:18 +0200 Subject: Specifying SourceUrl in version.config is optional --- scripts/configure.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/configure.cs b/scripts/configure.cs index 9f951b5c64..c34abb84e7 100644 --- a/scripts/configure.cs +++ b/scripts/configure.cs @@ -136,7 +136,7 @@ namespace MonoDevelop.Configuration Version = SystemUtil.Grep(versionTxt, @"Version=(.*)"); ProductVersionText = SystemUtil.Grep(versionTxt, "Label=(.*)"); CompatVersion = SystemUtil.Grep(versionTxt, "CompatVersion=(.*)"); - SourceUrl = SystemUtil.Grep(versionTxt, "SourceUrl=(.*)"); + SourceUrl = SystemUtil.Grep(versionTxt, "SourceUrl=(.*)", true); Version ver = new Version(Version); int vbuild = ver.Build != -1 ? ver.Build : 0; @@ -270,12 +270,15 @@ namespace MonoDevelop.Configuration public static Platform Platform { get; private set; } - public static string Grep(string file, string regex) + public static string Grep(string file, string regex, bool optional = false) { string txt = File.ReadAllText(file); var m = Regex.Match(txt, regex); - if (m == null) - throw new UserException("Match not found for regex: " + regex); + if (m == null || !m.Success) { + if (!optional) + throw new UserException ("Match not found for regex: " + regex); + return null; + } if (m.Groups.Count != 2) throw new UserException("Invalid regex: expression must have a single capture group: " + regex); Group cap = m.Groups[1]; -- cgit v1.2.3