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

Git/GitHub - branch protection #180700

Closed
2 tasks done
lszomoru opened this issue Apr 24, 2023 · 3 comments
Closed
2 tasks done

Git/GitHub - branch protection #180700

lszomoru opened this issue Apr 24, 2023 · 3 comments

Comments

@lszomoru
Copy link
Member

lszomoru commented Apr 24, 2023

Refs: #178990

Complexity: 4

Create Issue


This milestone we have refactored the branch protection code in the vscode.git extension to expose extension api that other extensions can leverage in order to provide branch protection information. This enables the GitHub extension to query repository rules and surface branch protection information in the workbench.

Since we have refactored the branch protection code, apart from testing the new capabilities we also want to confirm that we did not introduce any regressions.

Prerequisites

  1. Launch VS Code Insiders and open a folder/workspace that contains a git repository
  2. Open Settings, and reset the following settings: git.branchProtection, github.branchProtection

Git

  1. Launch VS Code Insiders and open a folder/workspace that contains a git repository
  2. Open Settings, and use the git.branchProtection setting to define protected branches (ex: main, release/*)
  3. Switch between branches that are protected, and ones that are not
    • Confirm that for protected branches a "lock" icon is being shown in the taskbar
  4. Switch to a protected branch, open settings and clear all items from the git.branchProtection setting
    • Confirm that the "lock" icon disappears after the setting has been updated

GitHub

The GitHub extension is using the recently announced repository rules to contribute branch protection information. As of right now, repositories rules are only read once, when the repository is opened as we still trying to determine when these rules should be refreshed.

  1. Create a new GitHub repository, or use an existing repository
  2. Enable the GitHub branch protection by setting github.branchProtection to true
  3. Use the documentation to create a new repository rule for "all branches" as target
  4. Open the git repository in VS Code
    • Confirm that no lock icon is being displayed in the status bar for any of the branches
  5. Edit the ruleset on GitHub, check the "Require a pull request before merging", and "Save Changes"
  6. Reload the window (this is needed as we only read repository rules when the repository is opened)
    • Confirm that the lock icon is being displayed in the status bar for all branches
  7. Edit the ruleset on GitHub, delete "all branches", add "default branch", and "Save Changes"
  8. Reload the window (this is needed as we only read repository rules when the repository is opened)
    • Confirm that the lock icon is being displayed for the default branch, but not the other branches
  9. Edit the ruleset on GitHub, add include/exclude patterns, and "Save Changes"
    • Confirm that the lock icon is being displayed for the branches that match the include patterns and do not match the exclude patterns
  10. Edit the ruleset on GitHub, change the "Enforcement status" from "Active" to "Disabled"
  11. Reload the window (this is needed as we only read repository rules when the repository is opened)
    • Confirm that the lock icon is not being displayed in the status bar for any of the branches
@lszomoru lszomoru added this to the April 2023 milestone Apr 24, 2023
@alexr00 alexr00 removed their assignment Apr 25, 2023
@digitarald digitarald removed their assignment Apr 26, 2023
@digitarald
Copy link
Contributor

This is amazing work!

@winstonhenke
Copy link

This is working for me when I have:
"git.branchProtection": ["main"]
"github.branchProtection": false

But as soon as I update "github.branchProtection": true it stops working (I have branch policies in place on main)

@lszomoru
Copy link
Member Author

lszomoru commented May 9, 2023

@winstonhenke, could you please file a separate issue and elaborate on what you means by "it stops working"? Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants