Skip to content

Instantly share code, notes, and snippets.

@wxianfeng
Last active December 14, 2015 10:18
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 wxianfeng/5070599 to your computer and use it in GitHub Desktop.
Save wxianfeng/5070599 to your computer and use it in GitHub Desktop.
自动更新redmine已指派到已解决.
由于git pull,push慢,一般我是多次commit,一次push. 并且在 commit 中填写 fix #xxx, 随手把pm上 issue的状态改为已解决. 不手动关的话,不够实时,没人点击版本库,测试人员看不到已解决.
手动关的话,带来一个问题,状态已解决, 测试人员就开始验证了,但是代码没push.
我写了个脚本自动化完成这个任务.
>vi .git/config
[push]
default = current
[alias]
xpush = !git push && .git/hooks/post-push
>touch .git/hooks/post-push && chmod +x .git/hooks/post-push
还有一种更方便的办法就是利用 git hooks, 但是需要在 git server 端配置.
以后利用
git xpush 替换 git push
# ref
http://blog.dougpetkanics.com/making-a-post-request-to-a-rails-api-endpoint/
http://fuzzytolerance.info/blog/use-a-git-hook-to-push-it-when-you-push-it/
http://gitbook.liuhui998.com/5_8.html
http://www.redmine.org/projects/redmine/wiki/Rest_api_with_curl
#!/usr/bin/env ruby
require 'httparty'
require 'json'
base = 'http://your.domain.com/pm'
# get login session cookie
login_url = "#{base}/login"
headers = { 'Content-Type' => 'application/json' }
body = { username: 'wangxianfeng', password: '' }.to_json
options = { body: body, headers: headers }
login_response = HTTParty.post(login_url,options)
login_cookie = login_response.headers['set-cookie']
# visit repo uri
repo_url = "#{base}/projects/isdev/repository"
repo_headers = { 'Cookie' => login_cookie }
HTTParty.get(repo_url,{ headers: repo_headers })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment