Python Git模块体验? [英] Python Git Module experiences?

查看:142
本文介绍了Python Git模块体验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是人们对Python的任何Git模块的经验? (我知道GitPython,PyGit和Dulwich--如果你知道他们,请随时提及其他人。)



我正在编写一个程序,它必须交互(add ,删除,提交)与Git存储库,但没有经验的Git,所以我要找的一件事就是易于使用/了解与Git。



我主要关心的其他事情是图书馆的成熟度和完整性,合理缺乏错误,继续开发以及文档和开发人员的帮助。



如果您想了解其他我可能想要/需要了解的内容,请随时提及。

我会回答我自己的问题,因为我采取了不同于答案中建议的方式。尽管如此,感谢那些回答。

首先,我对GitPython,PyGit和Dulwich的经验简要介绍:


  • GitPython :下载后,我得到了这个导入的适当的对象被初始化。但是,尝试执行教程中提出的建议会导致错误。缺少更多文档,我转向其他地方。

  • PyGit :这会甚至没有进口,我也找不到任何文件。

  • 德威:似乎是最有前途的(至少对于我想要和看到的)。我使用GitPython取得了一些进展,因为它的鸡蛋带有Python源代码。然而,过了一段时间,我决定尝试一下我所做的事可能会更容易。 StGit 看起来很有趣,但我需要将这些功能提取到一个单独的模块中,而不希望等到现在发生。

    $比上面的三个模块花费的时间少得多,我设法通过子进程模块获得git命令,例如

      def gitAdd(fileName,repoDir):
    cmd = ['git','add',fileName]
    p = subprocess .Popen(cmd,cwd = repoDir)
    p.wait()

    gitAdd('exampleFile.txt','/ usr / local / example_git_repo_dir')

    这还没有完全纳入我的程序中,但我没有预料到一个问题,除了可能的速度(因为我会有时会处理数百甚至数千个文件)。

    也许我只是没有耐心使用Dulwich或GitPython进行工作。也就是说,我希望这些模块能够得到更多的发展,并且很快就会更有用。


    What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)

    I am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use/understanding with regards to Git.

    The other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.

    If you think of something else I might want/need to know, please feel free to mention it.

    解决方案

    I thought I would answer my own question, since I'm taking a different path than suggested in the answers. Nonetheless, thanks to those who answered.

    First, a brief synopsis of my experiences with GitPython, PyGit, and Dulwich:

    • GitPython: After downloading, I got this imported and the appropriate object initialized. However, trying to do what was suggested in the tutorial led to errors. Lacking more documentation, I turned elsewhere.
    • PyGit: This would not even import, and I could find no documentation.
    • Dulwich: Seems to be the most promising (at least for what I wanted and saw). I made some progress with it, more than with GitPython, since its egg comes with Python source. However, after a while, I decided it may just be easier to try what I did.

    Also, StGit looks interesting, but I would need the functionality extracted into a separate module and do not want wait for that to happen right now.

    In (much) less time than I spent trying to get the three modules above working, I managed to get git commands working via the subprocess module, e.g.

    def gitAdd(fileName, repoDir):
        cmd = ['git', 'add', fileName]
        p = subprocess.Popen(cmd, cwd=repoDir)
        p.wait()
    
    gitAdd('exampleFile.txt', '/usr/local/example_git_repo_dir')
    

    This isn't fully incorporated into my program yet, but I'm not anticipating a problem, except maybe speed (since I'll be processing hundreds or even thousands of files at times).

    Maybe I just didn't have the patience to get things going with Dulwich or GitPython. That said, I'm hopeful the modules will get more development and be more useful soon.

    这篇关于Python Git模块体验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆