Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
Created November 7, 2014 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlidstrom/9fbccb3ffe899be06c2d to your computer and use it in GitHub Desktop.
Save dlidstrom/9fbccb3ffe899be06c2d to your computer and use it in GitHub Desktop.
Can be used to get a record of which files were associated with which Jira issues.
#foreach line in the input, until empty line
# [DateTime]::Parse('2014-05-28 12:43:43 +0200', [System.Globalization.CultureInfo]::InvariantCulture)
# try some (known) variations
$regex = New-Object System.Text.RegularExpressions.Regex('(?i)(HMO-|HMO -|HMO |HMO - )(\d+)')
$issueNumbers = @{}
$input | % { $regex.Matches($_) } | % {
$issueNumber = "HMO-$($_.Groups[2])"
if (-not $issueNumbers.ContainsKey($issueNumber))
{
$issueNumber
}
$issueNumbers[$issueNumber] = $true
}
param(
[Parameter(Mandatory=$true, HelpMessage="Supply path to repository")]
$Repository
)
$env:TERM = "msys"
$git = "${env:ProgramFiles(x86)}\Git\cmd\git.exe"
& $git "log" "--name-only" "--pretty=format:%h %ai %s" "--all" "--no-merges" "--since=6.months.ago"
param(
[Parameter(Mandatory=$true, HelpMessage="Supply path to repository")]
$Repository
)
$env:TERM = "msys"
$git = "${env:ProgramFiles(x86)}\Git\cmd\git.exe"
& $git "log" "--name-only" "--pretty=format:%h %ai %s" "--all" "--no-merges" "--since=6.months.ago"
# General idea:
# Foreach branch in origin:
# Foreach log entry since last checkpoint
# Foreach file in log entry
# Store file as a change set
#
# get branches using: git ls-remote --heads origin
# get name of current branch: git rev-parse --abbrev-ref HEAD
# get all logs using: git log --name-only --pretty=format:"%h %ai %s" --all --no-merges --since=6.months.ago
trap {
$_
}
$username = "tempdalid"
$password = [Text.Encoding]::ASCII.GetString([Convert]::FromBase64String("pwd-base-64-fmt"))
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$input | % {
$issue = Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json" -Uri http://jira.hm.com/rest/api/2/issue/$_
"$_ $($issue.fields.issuetype.name)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment