public override object GetDefault(VerbExecutionContext context) { var gitDir = GitRepo.Find("."); if (gitDir == null) throw new InvalidOperationException("Could not locate a git repository in the current directory or any of its ancestors."); // Read git repo from current path, if it exists. try { var lines = File.ReadAllLines(Path.Combine(gitDir, ".git", "config")); var remotes = lines .Select((line, i) => new { Line = line, Index = i }) // Only those lines that define a remote .Where(line => line.Line.StartsWith("[remote ")) // Grab url from following line. .Select(line => new { Remote = line.Line.Substring(9, line.Line.Length - 11), Url = lines[line.Index + 1].Trim() }) .ToList(); var remote = remotes .FirstOrDefault(x => x.Remote == "origin" || x.Remote == "upstream"); if (remote == null) remote = remotes.FirstOrDefault(); if (remote != null) { var match = urlExpr.Match(remote.Url); if (match.Success) return GetDefault(match.Groups["owner"].Value, match.Groups["repository"].Value); } } catch (IOException) { } return null; }
public override object GetDefault(VerbExecutionContext context) { throw new NotImplementedException(); }
public override object GetDefault(VerbExecutionContext context) { return "def2"; }
public override object GetDefault(VerbExecutionContext context) { return ConfigurationManager.AppSettings["apiToken"]; }