Created
November 12, 2011 10:33
-
-
Save chaliy/1360362 to your computer and use it in GitHub Desktop.
Commit to Mercurial with message from JIRA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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