V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
justfly
V2EX  ›  程序员

git 有没办法通过编程获取服务器上的 push 信息,用来做提醒。

  •  
  •   justfly · 2013-10-04 13:54:19 +08:00 · 3555 次点击
    这是一个创建于 3859 天前的主题,其中的信息可能已经有所发展或是发生改变。
    指定一个 git 远程仓库的地址,通过编程获取远程服务器谁 push 了代码,commit message 是什么。

    现在 git 支持 push 后发邮件,这个我知道,但是有没有办法在客户端去获取这些信息?
    11 条回复    1970-01-01 08:00:00 +08:00
    dongsheng
        1
    dongsheng  
       2013-10-04 14:03:39 +08:00
    man一下githooks,搜索pre-receive,在服务器的.git/hooks实现pre-receive就行了。
    yinian1992
        2
    yinian1992  
       2013-10-04 14:07:50 +08:00
    不想自己写就用 github 现成的 webhook
    justfly
        3
    justfly  
    OP
       2013-10-04 14:29:18 +08:00
    @dongsheng
    @yinian1992

    服务器 hook 肯定是可以的,我现在想做一个客户端通用的应用,不在服务器做任何设置,只要设置一个远程地址,每隔一段时间去刷新一下服务器 push 信息。我的问题是有可能在客户端获取服务器 push 信息吗?
    liangdi
        4
    liangdi  
       2013-10-04 14:47:46 +08:00 via Android
    定时pull 然后log 筛 日志
    yinian1992
        5
    yinian1992  
       2013-10-04 15:33:44 +08:00
    @justfly 定时查看 git log 呗。
    justfly
        6
    justfly  
    OP
       2013-10-04 15:34:38 +08:00
    @yinian1992 log 只是 pull 下来本地的,要知道服务器的还得先pull 再看 log 吧?
    yinian1992
        7
    yinian1992  
       2013-10-04 15:40:11 +08:00
    @justfly 登到服务器上 git log 也行啊。
    thyrlian
        8
    thyrlian  
       2013-10-04 16:00:04 +08:00
    AgileNotifier (https://github.com/thyrlian/AgileNotifier) 可以在任何客户端部署, 可以集成到Jenkins当做一个后续执行的Job, 也可以直接设置一个cron job, 目前支持本地git和github(包括企业版, 注意: github没有做auth, 所以每小时有60次的限制, 理论上1分钟1次都够用了). 当前的主要功能是如果job失败或者修复都可以提醒(通过没有做, 但留了接口, 因为没有意义, 没人关心通过). 亮点在于支持TTS, 目前支持中文, 英语, 德语, 西班牙语, 触发后(失败或者修复)能用设定语言骂提交者或者表扬之(目前完美支持MacOSX, 其它平台的TTS需要使用在线TTS服务, 因为语言支持不多, 所以没做完).

    最后, 配置极其简单, 几排DSL就可以搞定.

    例子:
    include AgileNotifier

    AgileNotifier::Configuration.set do
    ci_url 'http://x.x.x.x:8080'
    ci_job 'your-project-continuous-build'
    ci_get 'Jenkins'

    scm_url 'https://github.xyzcompany.com'
    scm_repo user: 'your_user_name', repo: 'your_repository_name'
    scm_get 'Github', enterprise: true

    # for non-enterprise version
    # scm_url 'https://api.github.com'
    # scm_repo user: 'your_user_name', repo: 'your_repository_name'
    # scm_get 'Github'

    speak 'en'
    play 'Boing' # Mac OSX Text to Speech voice name, optional field

    alert_on_fail
    alert_on_fix
    end
    thyrlian
        9
    thyrlian  
       2013-10-04 16:03:15 +08:00   ❤️ 1
    不好意思, 忘了说AgileNotifier目前不支持你要的commit message, 不过这个非常简单, 添几行进去就能实现了.
    mengzhuo
        11
    mengzhuo  
       2013-10-04 16:31:55 +08:00
    git hook就可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5425 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:01 · PVG 14:01 · LAX 23:01 · JFK 02:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.