Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Feature/add uri link to commit for targetprocess comment #1

merged 4 commits into from

2 participants


It would be nice to be able to link back to the commit on github from the story in TargetProcess.


Hi! Thanks for the pull request!

I see two things here. First, the simple line break (\n) may not display as a line break within TargetProcess - the comment blocks aren't wrapped in <pre> tags. That will need to (more than likely) be changed to a <br/>. Also, while you're in there, I would move the commit_url = commit["url"] line on line 40 outside the .each block (between lines 29 and 30) for consistency's sake and since there's no point in assigning the commit_url variable the same value over and over again.

If you could just take care of those two things and add the commit to this pull request, I'd be more than happy to merge.


  • Jonathan

Hope this works out better. It should be super helpful.

Thanks, Tom

@JonnyFunFun JonnyFunFun merged commit d853264 into JonnyFunFun:master
@JonnyFunFun JonnyFunFun referenced this pull request in github/github-services

Adding features to TP hook #240


Hi Tom,

I merged this request in with the code and submitted another pull request up to GitHub to merge it into their codebase (github/github-services#240). As soon as they've done their merge, the code should be live.


  • Jonathan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 2, 2012
  1. added commit url to the body of the commit message

    Thomas Hanley committed
Commits on Feb 10, 2012
  1. Ack... added a space between the br and slash

    Thomas Hanley committed
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 2 deletions.
  1. +4 −2 services/target_process.rb
6 services/target_process.rb
@@ -27,6 +27,7 @@ def valid_response?(res)
def process_commit(commit)
author = commit["author"]["email"]
+ commit_url = commit["url"]
commit["message"].split("\n").each { |commit_line|
parts = commit_line.match(/(\s|^)#(\d+)(:[^\s]+)?(\s|$)/)
next if parts.nil?
@@ -37,11 +38,11 @@ def process_commit(commit)
command = parts[3].strip
- execute_command(author, entity_id, command, commit_line)
+ execute_command(author, entity_id, command, commit_line, commit_url)
- def execute_command(author, entity_id, command, commit_message)
+ def execute_command(author, entity_id, command, commit_message, commit_url)
return if command.nil?
# get the user's id
res = http_get "api/v1/Users", {:where => "(Email eq '%s')" % author}
@@ -66,6 +67,7 @@ def execute_command(author, entity_id, command, commit_message)
new_state = begin Hash.from_xml(res.body)['Items']['EntityState']['Id'] rescue nil end
# Make it happen
http.headers['Content-Type'] = 'application/json'
+ commit_message = "#{commit_message}<br />Commit: #{commit_url}"
valid_response?(http_post "api/v1/Comments", "{General: {Id: #{entity_id}}, Description: '#{commit_message.gsub("'","\'")}', Owner: {Id: #{author_id}}}")
if !command.nil? and !new_state.nil?
valid_response?(http_post "api/v1/%s" % ((entity_type == "UserStory") ? "UserStories" : entity_type+'s'), "{Id: #{entity_id}, EntityState: {Id: #{new_state}}}")
Something went wrong with that request. Please try again.