Skip to content

Commit

Permalink
(chocolatey#1234) Something or other
Browse files Browse the repository at this point in the history
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf lkjdf lkj lkj lkj lkj asdfsadfasdf
lkjdf lkj lkj lkj lkj asdfsadfasdf
  • Loading branch information
corbob committed May 15, 2022
1 parent a468487 commit 27c0440
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions .husky/csx/commit-msg.csx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,44 @@ using System.Text.RegularExpressions;

private var titlePattern = @"^(?=.{0,50}$)(?:\(.*\)).*$";
private var commitFile = Args[0];
private var title = File.ReadAllLines(commitFile)[0];
private var commitMessage = File.ReadAllLines(commitFile);
private var title = commitMessage.FirstOrDefault();
private var exitCode = 0;
private var startLine = 2;
private var commitStringBuilder = new StringBuilder();
private var issuesStringBuilder = new StringBuilder();
private var lineStringBuilder = new StringBuilder();

if (Regex.IsMatch(title, titlePattern)) {
return 0;
if (!Regex.IsMatch(title, titlePattern)) {
issuesStringBuilder.AppendLine(@"Your title doesn't match the required format for the title");
exitCode++;
}

return 1;
commitStringBuilder.AppendLine(title);
commitStringBuilder.AppendLine();

// Determine if there is a blank line. We've already added it so we have no need to add it from the array.
if (!string.IsNullOrWhiteSpace(commitMessage[1])) {
startLine = 1;
}

for (int i = startLine ; i < commitMessage.Length ; i++) {
lineStringBuilder.Clear();
lineStringBuilder.Append(commitMessage[i]);
var lineDone = false;

while (!lineDone) {
if (lineStringBuilder.Length > 72) {
string str = lineStringBuilder.ToString();
int len = str.Substring(0,72).LastIndexOf(' ');
commitStringBuilder.AppendLine(str.Substring(0,len));
lineStringBuilder.Remove(0, len+1);
} else {
commitStringBuilder.AppendLine(lineStringBuilder.ToString());
lineDone = true;
}
}
}

File.WriteAllText(commitFile, commitStringBuilder.ToString());
return exitCode;

0 comments on commit 27c0440

Please sign in to comment.