Skip to content

Commit 67b8e6b

Browse files
Add docs on how we use version control
Co-authored-by: domoscargin <brett.kyle@digital.cabinet-office.gov.uk>
1 parent a1eb6ea commit 67b8e6b

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

source/how-we-work/index.html.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: How we work
3+
weight: 99
4+
---
5+
6+
# How we work
7+
8+
- [Version Control](./version-control/)
9+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Using version control (Git and GitHub)
3+
weight: 1
4+
---
5+
6+
# Using version control (Git and GitHub)
7+
8+
Most of our code and documentation is tracked using a version control system called [Git](https://git-scm.com/). Each of our projects is stored in a separate repository hosted on [GitHub](http://github.com/).
9+
10+
Using a version control system:
11+
12+
- lets multiple people work collaboratively on a set of changes before we publish them, without worrying about overwriting each other's work
13+
14+
- allows us to keep a detailed history of our code and documentation, meaning that we can go back and understand why we made a particular change
15+
16+
Git and GitHub are powerful but complex tools. When working with them it's expected that you'll need some support from other people in the team, especially if you are not a developer. Don't be afraid to ask for help.
17+
18+
The rest of this documentation assumes that you have some basic knowledge of Git, and understand terms like 'commits' and 'branches'. If you haven't used Git or GitHub before, you might want to try going through [GitHub's 'Hello World' exercise](https://docs.github.com/en/get-started/quickstart/hello-world) before reading on.
19+
20+
## Repositories
21+
22+
Our repositories are part of the 'alphagov' GitHub organisation. This organisation is shared with multiple teams across GDS.
23+
24+
[Our repos](https://github.com/topics/govuk-design-system-team) are tagged with the `govuk-design-system-team` label.
25+
26+
## Branches
27+
28+
The default branch for each of our repositories is called `main`. This is the branch that users will see by default when they visit the repository on GitHub.
29+
30+
The `main` branch is also an important branch in most of our projects, for example:
31+
32+
- the Design System and Frontend Docs websites will be updated whenever the `main` branch for their respective repo changes.
33+
34+
- when we do a release of GOV.UK Frontend, it's usually done from the `main` branch (or a support branch).
35+
36+
The main branch is protected using [branch protection rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches). This means that you can't make changes to it directly. Instead, you make changes by raising a Pull Request with the changes that you want to make.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Working with Pull Requests
3+
weight: 1
4+
---
5+
6+
# Working with Pull Requests (PRs)
7+
8+
## Making changes to PRs from external contributors
9+
10+
Occasionally, we need to help a contributor by making changes to their Pull Request before we can merge it. For example, we might offer to rebase their branch against main to save them time, or if they are not comfortable using git rebase.
11+
12+
You should let the contributor know that you are going to make changes to their branch, especially if it involves rewriting history – where possible, ask their permission first.
13+
14+
Contributors do not have write access to our repo, and so when they raise a PR it comes from [their own fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks) of the repository. This means that the process for making changes is slightly different, as any changes need to be made to their fork.
15+
16+
This requires the user to have [allowed maintainers to make changes to their branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/#enabling-repository-maintainer-permissions-on-existing-pull-requests). This is usually enabled by default, but if you have issues with permissions you may need to check that the user has this option enabled.
17+
18+
The easiest way to make a change to a contributor's PR is to use the [GitHub CLI](https://cli.github.com/). Once installed, you can run `gh pr checkout 1234`, replacing `1234` with the ID of the PR you want to work on.
19+
20+
The `gh pr checkout` command configures git so that changes are pushed to the contributor's fork when you run `git push` from the checked out branch. You can see how this works by running `git config --get-regexp branch.<BRANCH-NAME>`.
21+
22+
Note that:
23+
24+
- you should not specify any additional arguments when running `git push`
25+
- pushing the changes using a Git GUI (for example GitHub Desktop) may not work
26+
- pushing with `--force-with-lease` may not work (but `--force` should)
27+
28+
## Reviewing PRs
29+
30+
Consider who needs to review the Pull Request. If a PR includes code, design and guidance changes it may be appropriate for it to be reviewed by a developer, designer and a content designer. As a courtesy, you should consider at least giving those involved an opportunity to review it if they want to.
31+
32+
### Reviewing a PR from a team mate
33+
34+
PRs need to be reviewed and approved by at least 1 other team member. If you paired on a piece of work with another person, they can review and approve it.
35+
36+
### Reviewing a PR from an external contributor
37+
38+
PRs raised by external contributors need to be reviewed by 2 team members.
39+
40+
When reviewing PRs from external contributors:
41+
42+
- review the code using the GitHub interface before checking out the code and running it locally
43+
- be aware of [supply chain attacks](https://www.ncsc.gov.uk/collection/supply-chain-security) – check any new dependencies, and verify any changes to the [lock file](https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json)
44+
45+
### Reviewing a PR from Dependabot
46+
47+
Dependabot is configured to automatically raise Pull Requests to update our dependencies on a regular basis. These Pull Requests should be reviewed by developers.
48+
49+
Be aware of [supply chain attacks](https://www.ncsc.gov.uk/collection/supply-chain-security), especially if the maintainer of the dependency has changed (Dependabot usually flags this in the Pull Request).
50+
51+
If you want to check the changes being made to the dependency, use a tool like [Package Diff](https://diff.intrinsic.com/) which shows the difference between the published packages.
52+
53+
The PR should be reviewed by 2 developers if:
54+
55+
- it's a major version bump or the release notes suggest there are breaking changes
56+
- it changes the built site or package
57+
- a developer makes changes to the PR
58+
59+
Otherwise the pull request only needs to be reviewed by 1 developer.
60+
61+
## Merging Pull Requests
62+
63+
In order to merge a Pull Request to the main branch:
64+
65+
- all of the tests have to pass
66+
- the PR has to be reviewed and approved by at least 1 other person
67+
- the changes in the PR mustn't conflict with any other changes that might have been made (for example, if two people both try to change the same paragraph in some of our documentation)
68+
69+
Most of these requirements are enforced by GitHub, so you won't be able to merge the PR unless they're met.
70+
71+
It is the responsibility of the person who merges the PR to ensure that the changes have been reviewed by the right people, and that any concerns raised during the review process have been addressed.
72+
73+
### Merging a PR from a team mate
74+
75+
In most cases, the author of the PR should merge it.
76+
77+
If the author isn't around or free to merge a change, and it is blocking some other work or a release, then someone else from the team can merge it.
78+
79+
### Merging a PR from an external contributor or Dependabot
80+
81+
External contributors (including Dependabot) do not have write permissions to merge their own PR, so the PR should be merged by a team member as soon as all of the requirements are met.

0 commit comments

Comments
 (0)