Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created November 12, 2011 10:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chaliy/1360362 to your computer and use it in GitHub Desktop.
Save chaliy/1360362 to your computer and use it in GitHub Desktop.
Commit to Mercurial with message from JIRA
# Usage
# Commit-Project ABB-499
# This command will commit with message from issue ABB-499
# Commit-Project ABB-499 "Foo bar"
# This command will commit with message from issue ABB-499 and "Foo bar" at the end
#
# Script may once ask you JIRA url, your user name and password.
# You can use -Verbose modifier to get more details what script do
# Requires PsGet http://psget.net/
param(
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$true, Position=0)]
$Number,
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$false, Position=1)]
$Message = ""
)
ipmo PsGet
install-module PsUrl
install-module PsConfig
$jiraURL = Get-Setting JiraUrl -Prompt "Enter your JIRA server URL (e.g. http://jira.example.com)"
$username = Get-Setting JiraUsername -Prompt "Enter your JIRA user name"
$password = Get-Setting JiraPassword -Encripted -Prompt "Enter your JIRA password(will be stored encripted)"
$detailsUrl = "$jiraURL/si/jira.issueviews:issue-xml/$Number/$Number.xml?os_username=$username&os_password=$password"
Write-Verbose "Download JIRA issue details from $detailsUrl"
$details = [xml](get-url $detailsUrl -ErrorAction Stop)
$key = $details.rss.channel.item.key.innerText
$summary = $details.rss.channel.item.summary
$commitMessage = $key + " $summary."
if ($Message -ne ""){
$commitMessage += " $Message."
}
Write-Verbose "Commiting with message: $commitMessage"
hg commit -m $commitMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment