Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Specifying SourceUrl in version.config is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
slluis committed Sep 24, 2015
1 parent 651ab9a commit 4630560
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/configure.cs
Expand Up @@ -136,7 +136,7 @@ public IdeConfigurationTool(string monoDevelopPath)
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;
Expand Down Expand Up @@ -270,12 +270,15 @@ static SystemUtil ()

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];
Expand Down

0 comments on commit 4630560

Please sign in to comment.