Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Created December 13, 2015 11:44
Show Gist options
  • Save vgaltes/1ac9acba125c7e783994 to your computer and use it in GitHub Desktop.
Save vgaltes/1ac9acba125c7e783994 to your computer and use it in GitHub Desktop.
Whole function code
let extractCommitInfo (commit:string) =
let isCommitInfoLine (line: string) =
line.StartsWith("[")
let extractCommitedFilesInfo c =
let commitFileLine = CommitLineCsv.Parse(c).Rows |> Seq.head
{LinesAdded = commitFileLine.LinesAdded; LinesDeleted = commitFileLine.LinesDeleted; FileName = commitFileLine.FileName}
let commitLines = commit.Split([|lineBreak|], StringSplitOptions.RemoveEmptyEntries)
let commitInfoLine = commitLines |> Array.takeWhile(isCommitInfoLine) |> Array.last
let fileLines = commitLines |> Array.skipWhile(isCommitInfoLine)
let infoRow = CommitInfoCsv.Parse(commitInfoLine).Rows |> Seq.head
let commitInfo = {Hash = infoRow.Hash; Author = infoRow.Author; TimeStamp = infoRow.Date; Message = infoRow.Message}
let fileRows = fileLines |> Array.map extractCommitedFilesInfo
{CommitInfo = commitInfo; Files = fileRows}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment