• 请不要在回答技术问题时复制粘贴 AI 生成的内容
justfly
V2EX  ›  程序员

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

  •  
  •   justfly · Oct 4, 2013 · 4375 views
    This topic created in 4694 days ago, the information mentioned may be changed or developed.
    指定一个 git 远程仓库的地址,通过编程获取远程服务器谁 push 了代码,commit message 是什么。

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

    服务器 hook 肯定是可以的,我现在想做一个客户端通用的应用,不在服务器做任何设置,只要设置一个远程地址,每隔一段时间去刷新一下服务器 push 信息。我的问题是有可能在客户端获取服务器 push 信息吗?
    liangdi
        4
    liangdi  
       Oct 4, 2013 via Android
    定时pull 然后log 筛 日志
    yinian1992
        5
    yinian1992  
       Oct 4, 2013
    @justfly 定时查看 git log 呗。
    justfly
        6
    justfly  
    OP
       Oct 4, 2013
    @yinian1992 log 只是 pull 下来本地的,要知道服务器的还得先pull 再看 log 吧?
    yinian1992
        7
    yinian1992  
       Oct 4, 2013
    @justfly 登到服务器上 git log 也行啊。
    thyrlian
        8
    thyrlian  
       Oct 4, 2013
    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  
       Oct 4, 2013   ❤️ 1
    不好意思, 忘了说AgileNotifier目前不支持你要的commit message, 不过这个非常简单, 添几行进去就能实现了.
    mengzhuo
        11
    mengzhuo  
       Oct 4, 2013
    git hook就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5262 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 01:19 · PVG 09:19 · LAX 18:19 · JFK 21:19
    ♥ Do have faith in what you're doing.