V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
zhoudaiyu
V2EX  ›  问与答

Python 怎么实现 git pull 拉取 gitlab 上的项目文件?

  •  
  •   zhoudaiyu ·
    PRO
    · Apr 1, 2021 · 1667 views
    This topic created in 1857 days ago, the information mentioned may be changed or developed.

    比如通过 web 触发,主动去 gitlab 拉代码,和本地文件同步,只是增量更新,不是文件下载。我看了看 http api 或者 gitlab-python 好像都不能实现这个功能,大家有啥思路吗?

    4 replies    2021-04-02 17:32:41 +08:00
    Vegetable
        1
    Vegetable  
       Apr 1, 2021   ❤️ 1
    阿这,难道不能这样?
    os.system("git pull")
    wayslog
        2
    wayslog  
       Apr 1, 2021
    subprocess.check_call(shlex.split('git pull ....'))
    Misakas
        3
    Misakas  
       Apr 2, 2021
    os.system("cd /home/workspace/ && git pull ")。楼上的都不严谨(狗头
    tingyunsay
        4
    tingyunsay  
       Apr 2, 2021
    import commands
    commands.getstatusoutput("/usr/bin/git pull")
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2576 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 06:59 · PVG 14:59 · LAX 23:59 · JFK 02:59
    ♥ Do have faith in what you're doing.