socialforge/lib/git_refresh_changes.py

31 lines
887 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#coding=utf-8
#!/usr/bin/env python
# 脚本用于刷新版本库由git hooks里进行调用传入参数为git仓库路径
# 需要配置rails项目地址
# 必须装此文件放在git的存放目录现在是 /home/pdl/redmine-2.3.2-0/apache2/htdocs
import sys
import os
import urllib
import urllib2
RAILS_URL = 'http://192.168.128.128:3000/'
def get_git_path():
return sys.argv[1]
path=os.path.realpath(sys.argv[0])
if os.path.isfile(path):
path=os.path.dirname(os.path.dirname(path))
return os.path.abspath(path)
def post_http_data(url, data):
data_urlencode = urllib.urlencode(data)
req = urllib2.Request(url = url,data =data_urlencode)
res_data = urllib2.urlopen(req)
#res = res_data.read()
#return res
path = get_git_path()
post_http_data(RAILS_URL + 'git_callback/post_update', {'root_url': path})