Skip to content

Commit 5486e43

Browse files
committed
[docs] Add notes on useful integration tooling and config
1 parent 8a7b2f9 commit 5486e43

File tree

1 file changed

+94
-0
lines changed
  • general/development/process/integration

1 file changed

+94
-0
lines changed

general/development/process/integration/index.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,99 @@ As a general rule, this means that if your issue has entered the 'in integration
166166
The Integration team will sometimes recommend squashing commits when things do not look natural (and may offer to do this for you), especially when there are "fix-commits" in the history happening before integration. You will not be forced to squash your changes because our policy is: *"If you want your history of commits to look like bad, it's your history."*.
167167

168168
:::tip
169+
169170
You should pay close attention to [Git_commits](../../policies/codingstyle/index.md#git-commits) and intend to *"Tell a perfect, cleaned up version of the history. As if the code was written perfectly first time."*.
171+
172+
:::
173+
174+
## Integration tooling
175+
176+
Typically during the integration process no additional tooling is required, however the [`moodle-userscripts`](https://github.com/HuongNV13/moodle-userscripts) TamperMonkey scripts are a great way of generating the commands typically used during final code review.
177+
178+
:::danger Considerations for your code review repository
179+
180+
When reviewing code for the final review, it is important to do so in a separate checkout which you do not use for other development. This helps ensure that unrelated branches and changes are not pushed by mistake.
181+
182+
- Before starting a review, ensure you have fetched the latest data from the Git remote
183+
- It is advisable to remove all unrelated branches to prevent inadvertent branch pushing
184+
170185
:::
186+
187+
### Useful configuration
188+
189+
The following configuration can be applied in your global git configuration:
190+
191+
```console title="~/.gitconfig"
192+
[alias]
193+
# Display the name of the current branch.
194+
current-branch = !git branch|grep ^\\*|cut -d\\ -f2
195+
196+
# Get a list of all other branches.
197+
other-branches = !git branch|grep -v ^\\*
198+
199+
# Remove all branches other than the one currently checked out.
200+
remove-other-branches = !git branch -D `git other-branches`
201+
202+
# Fetch from the Moodle Remote and then reset the current branch.
203+
integration-reset = !git fetch origin && git reset --hard origin/`git current-branch`
204+
205+
# Diff the current branch against the remote version of this branch, fetching first.
206+
integration-diff = !git fetch origin && git show --stat=500,300 -p origin/`git current-branch`...`git current-branch`
207+
208+
# Diff the current branch, ignoring whitespace, against the remote version of this branch, fetching first.
209+
integration-wdiff = !git fetch origin && git show --color-words --stat=500,300 -p origin/`git current-branch`...`git current-branch`
210+
```
211+
212+
The following configuration should only be applied to the git configuration used for your final reviews.
213+
214+
```console title="[path/to/repository/].git/config"
215+
[alias]
216+
# This is a more aggressive form of the standard integration-reset.
217+
# It should *only* be applied to your final review policy.
218+
# It will remove all branches other than the currently checked out branch.
219+
# DO NOT use this config on a repository you care about.
220+
integration-reset = !git fetch origin && git reset --hard origin/`git current-branch` && git remove-other-branches
221+
```
222+
223+
The following are useful bash/zsh aliases which you may also find useful:
224+
225+
```console title="~/.bashrc"
226+
# Alias the `id` command to perform a diff on the current branch.
227+
alias id='git integration-diff'
228+
229+
# Alias the `ir` command to perform a reset for the current branch only.
230+
alias ir='git integration-reset'
231+
232+
# Alias the `irm` command to check out the `main` branch and the remove all other branches.
233+
alias irm='git checkout main; git integration-reset'
234+
```
235+
236+
### Typical workflow
237+
238+
1. Reset your code review checkout:
239+
240+
```sh
241+
irm
242+
```
243+
244+
2. Check the Test results in:
245+
246+
- GitHub Actions
247+
- TOBIC
248+
- CIBot
249+
250+
3. For each branch under review:
251+
252+
1. Copy the branch details using the "Merge command" button
253+
2. Paste it into the console for your code review checkout
254+
3. Resolve any merge conflicts and commit the merge
255+
4. Run the integration diff command:
256+
257+
```sh
258+
id
259+
```
260+
261+
5. Check the output for any problems
262+
263+
4. Use the "Push command" button to copy a `git push` command into your paste biuffer
264+
5. Paste it into your console, and review before pushing the code.

0 commit comments

Comments
 (0)