Skip to content

Commit a6c231e

Browse files
committed
Improve content of the documentation
1 parent 730a804 commit a6c231e

File tree

2 files changed

+72
-32
lines changed

2 files changed

+72
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Most of the projects are built with customisability and extendability in mind. A
5151

5252
Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like
5353

54-
- Environment setup for contribution, i.e. `CONTRIBUTING.md`
54+
- Environment setup for contribution, i.e. [CONTRIBUTING.md](./docs/CONTRIBUTING.md)
5555
- Coding standards, branching, linting, practices for development and testing
5656
- Release process, versioning, changelog
5757
- Backlog, board, roadmap, ways of working

docs/CONTRIBUTING.md

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Git configuration](#git-configuration)
1212
- [Signing commits](#signing-commits)
1313
- [Troubleshooting](#troubleshooting)
14+
- [Additional settings](#additional-settings)
1415
- [Usage](#usage)
1516
- [Commit message](#commit-message)
1617
- [Hooks](#hooks)
@@ -31,9 +32,9 @@
3132

3233
The following software packages must be installed on your laptop before proceeding
3334

34-
- [GNU make](https://formulae.brew.sh/formula/make)
3535
- [GitHub CLI](https://cli.github.com/)
36-
- ...
36+
- [GNU make](https://formulae.brew.sh/formula/make)
37+
- [Docker](https://www.docker.com/)
3738

3839
To ensure all the prerequisite are installed and configured correctly, please follow the [nhs-england-tools/dotfiles](https://github.com/nhs-england-tools/dotfiles) installation process.
3940

@@ -55,15 +56,16 @@ The commands below will configure your Git command-line client globally. Please,
5556
This configuration is to support trunk-based development and git linear history.
5657

5758
```shell
58-
git config --global user.name "Your Name" # Use your full name here
59-
git config --global user.email "youremail@domain" # Use your email address here
59+
git config user.name "Your Name" # Use your full name here
60+
git config user.email "youremail@domain" # Use your email address here
6061
git config branch.autosetupmerge false
6162
git config branch.autosetuprebase always
6263
git config commit.gpgsign true
6364
git config core.autocrlf input
6465
git config core.filemode true
6566
git config core.hidedotfiles false
6667
git config core.ignorecase false
68+
git config credential.helper cache
6769
git config pull.rebase true
6870
git config push.default current
6971
git config push.followTags true
@@ -78,14 +80,17 @@ More information on the git settings can be found in the [Git Reference document
7880
Signing Git commits is a good practice and ensures the correct web of trust has been established for the distributed version control management.
7981

8082
<!-- markdownlint-disable-next-line no-inline-html -->
81-
Generate a new pair of GPG keys. Please, change the passphrase (<span style="color:red">pleaseChooseYourKeyPassphrase</span>) below and save it in your password manager.
83+
If you do not have it already generate a new pair of GPG keys. Please, change the passphrase (<span style="color:red">pleaseChooseYourKeyPassphrase</span>) below and save it in your password manager.
8284

8385
```shell
8486
USER_NAME="Your Name"
85-
USER_EMAIL="your.name@nhs.net"
87+
USER_EMAIL="your.name@email"
8688
file=$(echo $USER_EMAIL | sed "s/[^[:alpha:]]/-/g")
8789

88-
cat > $file.gpg-key.script <<EOF
90+
mkdir -p "$HOME/.gnupg"
91+
chmod 0700 "$HOME/.gnupg"
92+
cd "$HOME/.gnupg"
93+
cat > "$file.gpg-key.script" <<EOF
8994
%echo Generating a GPG key
9095
Key-Type: ECDSA
9196
Key-Curve: nistp256
@@ -98,7 +103,8 @@ cat > $file.gpg-key.script <<EOF
98103
%commit
99104
%echo done
100105
EOF
101-
gpg --batch --generate-key $file.gpg-key.script && rm $file.gpg-key.script
106+
gpg --batch --generate-key "$file.gpg-key.script"
107+
rm "$file.gpg-key.script"
102108
# or do it manually by running `gpg --full-gen-key`
103109
```
104110

@@ -108,12 +114,12 @@ Make note of the ID and save the keys.
108114
gpg --list-secret-keys --keyid-format LONG $USER_EMAIL
109115
```
110116

111-
You should see a similar output to this:
117+
You should see a similar output to this
112118

113119
```shell
114120
sec nistp256/AAAAAAAAAAAAAAAA 2023-01-01 [SCA]
115121
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
116-
uid [ultimate] Your Name <your.name@nhs.net>
122+
uid [ultimate] Your Name <your.name@email>
117123
ssb nistp256/BBBBBBBBBBBBBBBB 2023-01-01 [E]
118124
```
119125

@@ -141,41 +147,75 @@ gpg --delete-keys $ID
141147
Configure Git to use the new key.
142148

143149
```shell
144-
git config --global user.signingkey $ID
145-
git config --global commit.gpgsign true
150+
git config user.signingkey $ID
146151
```
147152

148-
Upload the public key to your GitHub profile in the [GPG keys](https://github.com/settings/keys) section. After doing so, please make sure your email address appears as verified against the commits pushed to the remote.
153+
Upload the public key to your GitHub profile into the [GPG keys](https://github.com/settings/keys) section. After doing so, please make sure your email address appears as verified against the commits pushed to the remote.
154+
155+
```shell
156+
cat $file.gpg-key.pub
157+
```
149158

150159
#### Troubleshooting
151160

152161
If you receive the error message "error: gpg failed to sign the data", make sure you added `export GPG_TTY=$(tty)` to your `~/.zshrc` and restarted your terminal.
153162

154163
```shell
155-
sed -i '' '/^export GPG_TTY/d' ~/.zshrc
156-
echo export GPG_TTY=\$\(tty\) >> ~/.zshrc
164+
sed -i '/^export GPG_TTY/d' ~/.exports
165+
echo "export GPG_TTY=\$TTY" >> ~/.exports
157166
```
158167

159-
Additional useful settings and commands
168+
## Additional settings
169+
170+
Configure caching git commit signature passphrase for 3 hours
160171

161172
```shell
162173
source ~/.zshrc
163-
sed -i '' '/^pinentry-program/d' ~/.gnupg/gpg-agent.conf
174+
mkdir -p ~/.gnupg
175+
sed -i '/^pinentry-program/d' ~/.gnupg/gpg-agent.conf 2>/dev/null ||:
164176
echo "pinentry-program $(whereis -q pinentry)" >> ~/.gnupg/gpg-agent.conf
165-
sed -i '' '/^default-cache-ttl/d' ~/.gnupg/gpg-agent.conf
177+
sed -i '/^default-cache-ttl/d' ~/.gnupg/gpg-agent.conf
166178
echo "default-cache-ttl 10800" >> ~/.gnupg/gpg-agent.conf
167-
sed -i '' '/^max-cache-ttl/d' ~/.gnupg/gpg-agent.conf
179+
sed -i '/^max-cache-ttl/d' ~/.gnupg/gpg-agent.conf
168180
echo "max-cache-ttl 10800" >> ~/.gnupg/gpg-agent.conf
169181
gpgconf --kill gpg-agent
182+
git config --global credential.helper cache
183+
#git config --global --unset credential.helper
170184
```
171185

186+
Authenticate to GitHub and set up your authorisation token
187+
172188
```shell
173-
git config --global credential.helper cache
174-
#git config --global --unset credential.helper
189+
$ gh auth login
190+
? What account do you want to log into? GitHub.com
191+
? What is your preferred protocol for Git operations? HTTPS
192+
? Authenticate Git with your GitHub credentials? No
193+
? How would you like to authenticate GitHub CLI? Paste an authentication token
194+
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
195+
The minimum required scopes are 'repo', 'read:org'.
196+
? Paste your authentication token: github_pat_**********************************************************************************
197+
- gh config set -h github.com git_protocol https
198+
✓ Configured git protocol
199+
✓ Logged in as your-github-handle
175200
```
176201

202+
Add your changes, create a signed commit, update from and push to remote
203+
177204
```shell
178-
gh auth login
205+
git add .
206+
git commit -S -m "Create a signed commit"
207+
git pull
208+
git push
209+
```
210+
211+
Squash all commits on branch as one
212+
213+
```shell
214+
git checkout your-branch-name
215+
git reset $(git merge-base main $(git branch --show-current))
216+
git add .
217+
git commit -S -m "Create just one commit instead"
218+
git push --force-with-lease
179219
```
180220

181221
### Usage
@@ -197,7 +237,7 @@ There are a couple of good cheatsheets by [GitHub](https://training.github.com/d
197237

198238
Working on a new task
199239

200-
```console
240+
```shell
201241
git checkout -b task/REF-XXX_Descriptive_branch_name
202242
# Make your changes here...
203243
git add .
@@ -207,7 +247,7 @@ git push --set-upstream origin task/REF-XXX_Descriptive_branch_name
207247

208248
Contributing to an already existing branch
209249

210-
```console
250+
```shell
211251
git checkout task/REF-XXX_Descriptive_branch_name
212252
git pull
213253
# Make your changes here...
@@ -218,7 +258,7 @@ git push
218258

219259
Squashing commits within a branch
220260

221-
```console
261+
```shell
222262
git checkout task/REF-XXX_Descriptive_branch_name
223263
git rebase -i HEAD~X # Squash X number of commits into one
224264
# When prompted change commit type to `squash` for all the commits except the top one
@@ -228,7 +268,7 @@ git push --force-with-lease
228268

229269
Rebasing a branch onto main
230270

231-
```console
271+
```shell
232272
git checkout main
233273
git pull
234274
git checkout task/REF-XXX_Descriptive_branch_name
@@ -241,7 +281,7 @@ git push --force-with-lease
241281

242282
Merging a branch to main - this should be done only in an exceptional circumstance as the proper process is to raise a Pull Request
243283

244-
```console
284+
```shell
245285
git checkout main
246286
git pull --prune # Make sure main is up-to-date
247287
git checkout task/REF-XXX_Descriptive_branch_name
@@ -271,9 +311,11 @@ If REF is currently not in use to track project changes, please drop any referen
271311
- Wrap lines at 72 characters
272312
- Use the body to explain what and why you have done something, which should be done as part of a Pull Request description
273313

314+
*(Please, bear in mind that a need for this might be superseded by the GitHub Pull Request setting in your respoitory `Settings > General > Pull Requests > Allow squash merging > Default to pull request title and description` which is a recommended configuration.)*
315+
274316
Example:
275317

276-
```console
318+
```shell
277319
Short (72 chars or less) summary in the imperative mood
278320

279321
More detailed explanatory text. Wrap it to 72 characters. The blank
@@ -347,7 +389,7 @@ Read the [Code of Conduct](../docs/CODE_OF_CONDUCT.md) to keep the community app
347389

348390
When writing or updating unit tests (whether you use Python, Java, Go or shell), please always structure them using the 3 A's approach of 'Arrange', 'Act', and 'Assert'. For example:
349391

350-
```console
392+
```java
351393
@Test
352394
public listServicesNullReturn() {
353395

@@ -364,8 +406,6 @@ public listServicesNullReturn() {
364406
}
365407
```
366408

367-
TDD ?
368-
369409
### Code review
370410

371411
Whether possible, please practice pair or/and mob programming. While performing code reviews, please refer to the [Clean Code](https://learning.oreilly.com/library/view/clean-code/9780136083238/) (especially chapter 17) and [Clean Architecture](https://learning.oreilly.com/library/view/clean-architecture-a/9780134494272/) books written by Robert C. Martin.

0 commit comments

Comments
 (0)