protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { foreach (var affectedItem in repoChangeInfo.AffectedItems) { if (this.ItemMeetsCondition(affectedItem)) { State = true; return; } } State = false; }
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { foreach (var affectedItem in repoChangeInfo.AffectedItems) { if (this.ItemMeetsCondition(affectedItem)) { State = true; return; } } State = false; }
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { State = this.authors.Contains(repoChangeInfo.Author); }
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { State = this.logMessageRegExPattern.IsMatch(repoChangeInfo.LogMessage); }
protected abstract void UpdateState(IRepoChangeInfo repoChangeInfo);
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { State = this.authors.Contains(repoChangeInfo.Author); }
static void Main(string[] args) { InitializeLog4Net(); try { ////args = new string[] { "pre", @"C:\temp\DummyRepo\", "kilgkfhb" }; ////args = new string[] { "post-commit", @"C:\temp\repositories\dummy", "35" }; log.DebugFormat("{0} started", AppDomain.CurrentDomain.FriendlyName); if (args.Length > 2) { log.DebugFormat("Argument0: [{0}] - Argument1: [{1}] - Argument2: [{2}]", args[0], args[1], args[2]); } string actionArgument = null; if (args.Length > 0) { actionArgument = args[0]; } if (!ProcessParameters(args)) { Environment.ExitCode = 1; return; } IRepoChangeInfo repoChangeInfo = null; string repositoryPath; switch (actionArgument) { case "validate": if (HookManager.Validate(out var text)) { Console.Out.WriteLine("Configuration file was successfully parsed."); Console.Out.WriteLine(text); Environment.ExitCode = 0; } else { Console.Out.WriteLine("Validation encountered an error. Please check log for details."); Environment.ExitCode = 1; } break; case "start-commit": if (args.Length > 3) { repositoryPath = args[1]; var username = args[2]; var capabilities = args[3]; log.Debug("start-commit hook using these settings:"); log.DebugFormat("Repository path: [{0}]", repositoryPath); log.DebugFormat("Username: [{0}]", username); log.DebugFormat("Client capabilities: [{0}]", capabilities); } else { log.Error("Insufficient parameters for start-commit."); } break; case "pre-commit": if (args.Length > 2) { repositoryPath = args[1]; var transaction = args[2]; repoChangeInfo = GetPreCommitRepoChangeInfo(repositoryPath, transaction); } else { log.Error("Insufficient parameters for start-commit."); } break; case "post-commit": if (args.Length > 2) { repositoryPath = args[1]; long revision; if (Int64.TryParse(args[2], out revision)) { repoChangeInfo = GetPostCommitRepoChangeInfo(repositoryPath, revision); } else { System.Console.Error.WriteLine("Could not parse {0} as revision number.", args[2]); Environment.ExitCode = 2; } } else { log.Error("Insufficient parameters for start-commit."); } break; default: System.Console.Error.WriteLine("Unsupported hook type. Use either pre oder post as first argument."); break; } if (repoChangeInfo != null) { if (!HookManager.Execute(repoChangeInfo)) { Environment.ExitCode = 1; } } } catch (Exception e) { Console.WriteLine("An error occured: {0}", e); log.Error("An error occured", e); } }
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { State = this.logMessageRegExPattern.IsMatch(repoChangeInfo.LogMessage); }
protected abstract void UpdateState(IRepoChangeInfo repoChangeInfo);
protected override void UpdateState(IRepoChangeInfo repoChangeInfo) { this.State = (this.HookType == HookType.Undefined) || (this.HookType == repoChangeInfo.HookType); }