search

Home  >  Q&A  >  body text

node.js - 如何用nodejs被动从git上拉取项目?

公司在做一个项目,要求用nodejs被动从git上拉取项目,就是git上的代码有更新(同事有提交代码),就给nodejs发消息,nodejs监听到消息后,从git上拉取,更新本地文件,其实就是代替手动拉取代码,获取git是用的nodegit插件,希望大家给些建议,谢谢!

怪我咯怪我咯2877 days ago691

reply all(4)I'll reply

  • 黄舟

    黄舟2017-04-17 13:50:57

    I have never done this kind of thing before, but I feel like your idea is of little use and is just superfluous. For example, if you are writing code and a colleague submits it, you will passively update the code. If a conflict occurs, you will have to stop and deal with the conflict, and your train of thought will be interrupted. Also, many projects now carry out branch management. Even if a colleague submits it, it may not be on your branch, and it will be useless if you update it.
    For this idea, you can use a method similar to mobile phone push. When the server detects a code update, it pushes it to the client. The client has a script to receive the push and send a request to update the code. That's all I can think of, but this idea feels really useless. The time to manually update the code should not be longer than the time it takes you to develop this feature.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:50:57

    git hook

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:50:57

    Webhook

    reply
    0
  • PHPz

    PHPz2017-04-17 13:50:57

    Git provides Webhook. You can find it in the project Settings.

    To put it simply, if the project changes, a POST request will be sent to the specified URL according to your settings. In this way, the corresponding processing can be carried out according to the POST request. For details, please see the manual

    PS:
    Many automated deployment tools use this, such as Travis CI Strider-CD. If you don’t build it yourself, you can use these, which are highly integrated and can be deployed automatically. Please pay attention to the License.

    reply
    0
  • Cancelreply