Bazel是一个构建和测试工具,git_repository和new_git_repository都是Bazel中可用的函数,它们都用于从Git存储库中检索文件并将其添加到项目中。 但是它们之间有一些区别。git_repository函数需要给出一个名称和一个远程git存储库的URL,该存储库用于检索代码。而new_git_repository函数允许设置额外的参数,例如分支名称和提交哈希值等。 在使用时,可以根据需要使用其中一个函数。
以下是使用这两个函数的示例:
使用git_repository函数:
git_repository( name = "hello-world", remote = "https://github.com/username/hello-world.git", tag = "v1.0" )
使用new_git_repository函数:
new_git_repository( name = "hello-world", remote = "https://github.com/username/hello-world.git", branch = "master", commit = "1234567890abcdefg" )