Skip to content

Make new_git_repository fail if used - #29226

Closed
willstranton wants to merge 1 commit into
bazelbuild:masterfrom
willstranton:rm_new_git
Closed

willstranton wants to merge 1 commit into
bazelbuild:masterfrom
willstranton:rm_new_git

Conversation

@willstranton

@willstranton willstranton commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

The note in git.bzl says that 'new_git_repository' should be removed by Bazel
7. This removes it since it's just an alias of git_repository replaces it with a failure message and fix instructions. Users should use git_repository instead of new_git repository.

Description

Replaces the implementation of the repository rule new_git_repository with an implementation that fails immediately when used.

Example error message:

Error in fail:
    The repository rule 'new_git_repository' is deprecated. To fix, replace usage of
    'new_git_repository' with the drop-in replacement 'git_repository' in your MODULE.bazel file.
    Eg.

    Replace the following:

    new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
    new_git_repository(
        name = "bazel",
        remote = "https://github.com/bazelbuild/bazel.git",
        commit = "93f38093f8e24875c1d015e67311853756bdb27e"
    )

    With:

    git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
    git_repository(
        name = "bazel",
        remote = "https://github.com/bazelbuild/bazel.git",
        commit = "93f38093f8e24875c1d015e67311853756bdb27e"
    )

Motivation

The note in git.bzl says this should have been removed before Bazel 7. We are now at Bazel 9.

Build API Changes

  1. Has this been discussed in a design doc or issue? (Please link it)

I have no knowledge of a discussion taking place on this. The note in git.bzl saying this should be removed implies that there was such a discussion or intent.

  1. Is the change backward compatible?

No, anyone who is using new_git_repository will fail after getting this change.

  1. If it's a breaking change, what is the migration plan?

Users should use git_repository instead.

Checklist

  • [N/A] I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES[INC]: Removes the deprecated repository rule new_git_repository. Users should use git_repository instead (they are the same)

@willstranton
willstranton marked this pull request as ready for review April 4, 2026 02:05
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Apr 4, 2026

@fmeum fmeum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iancha1992 iancha1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Apr 6, 2026
@meisterT

meisterT commented Apr 7, 2026

Copy link
Copy Markdown
Member

please move the RELNOTES[INC] into your commit description, I don't think we are picking this up from the PRs

@meteorcloudy

Copy link
Copy Markdown
Member

nit: Can you leave a thin macro new_git_repository behind with an error message? It'll help users migrate (but hopefully no one is using it with Bzlmod).

The note in git.bzl says that 'new_git_repository' should be removed by Bazel
7. This replaces the rule implementation with one that fails immediately if
used and informs the user on how to replace it with the drop-in replacement
'git_repository'

RELNOTES[INC]: Prevent use of the repository rule `new_git_repository`. Users should use git_repository instead (it's a drop-in replacement)
@willstranton

Copy link
Copy Markdown
Contributor Author

please move the RELNOTES[INC] into your commit description, I don't think we are picking this up from the PRs

Done

nit: Can you leave a thin macro new_git_repository behind with an error message? It'll help users migrate (but hopefully no one is using it with Bzlmod).

Done. Added a TODO that it should eventually be removed.

@willstranton willstranton changed the title Remove new_git_repository rule Make new_git_repository fail if used Apr 7, 2026

@meteorcloudy meteorcloudy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants