Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor git_repository and new_git_repository rules implementations … #8264

Closed
wants to merge 6 commits into from
Closed

Refactor git_repository and new_git_repository rules implementations … #8264

wants to merge 6 commits into from

Conversation

irengrig
Copy link
Contributor

@irengrig irengrig commented May 8, 2019

…so that they can be used with Bazel on Windows without MSYS

  • do not use shell scripting, call git binary and use repository_context methods
  • add black box tests for new_git_repository, so that they run on Windows without MSYS
  • prefer fetch to clone, as in that case less content is fetched (with fetch, we specify both the reference and depth in the same command; on contrary, clone will fetch all branches)

…so that they can be used with Bazel on Windows without MSYS

- do not use shell scripting, call git binary and use repository_context methods
- add black box tests for new_git_repository, so that they run on Windows without MSYS
- prefer fetch to clone, as in that case less content is fetched (with fetch, we specify both the reference and depth in the same command; on contrary, clone will fetch all branches)
@irengrig
Copy link
Contributor Author

irengrig commented May 8, 2019

NB probably Buildkite Windows image should be updated, the git fails with a weird error.

@irengrig irengrig requested a review from meteorcloudy May 8, 2019 14:44
@irengrig irengrig added area-Windows Windows-specific issues and feature requests WIP labels May 8, 2019
if ctx.attr.shallow_since:
shallow = "--shallow-since=%s" % ctx.attr.shallow_since
if ctx.attr.commit:
shallow = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems wrong. The reproducible case is that we specify a commit and a shallow_since value to allow shallow cloning. But your code seems to erase the value of shallow in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will have another look tomorrow. (Of course the contract should stay).
Also, maybe you could point to a test for this specific combination?

NB this PR is mostly for passing my already-prepared changes to Yun, it's gonna be some work with this stuff before it gets submitted.

Copy link
Member

Choose a reason for hiding this comment

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

The tests are now passing on Windows. @irengrig Can you address Klaus's comment or should I look into it? Is there anything else I should do before getting this merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current code works exactly the same way as the previous variant:

if ctx.attr.commit:

Before refactoring, if the commit was specified, and no shallow_since, the commit value was not used for shallow variable.
Please note that we can not call "fetch" with the commit number, only with tag/branch/HEAD (isaacs/github#436), but maybe we could indeed use the --shallow_since attribute in this case.

@meteorcloudy
Copy link
Member

I'm investigating the test failure on Windows. Seems like a conflict between Git on Windows and MSYS2, still trying to reproduce locally.

- do not try to pass empty shallow argument, and do not quote it
- when user specified commit hash, use it as shallow_since argument
Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

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

Thanks for doing this refactor! @aehlig Can you also take a look?

@meteorcloudy
Copy link
Member

@irengrig Can you import this PR?

@irengrig
Copy link
Contributor Author

@irengrig Can you import this PR?

Sure, will do that

@irengrig
Copy link
Contributor Author

irengrig commented Jul 3, 2019

This was submitted in the other PR: #8677

@irengrig irengrig closed this Jul 3, 2019
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests cla: yes team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants