Skip to content

Commit 8b6f3c7

Browse files
committed
screenshots for second exercise
1 parent 4c93a8d commit 8b6f3c7

6 files changed

Lines changed: 78 additions & 2 deletions

File tree

content/code-review.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,82 @@ previous episode.
4444
:::
4545

4646

47-
## Solution and walk-through
47+
## Help and discussion
4848

49-
We will add this before the lesson.
49+
### How to ask for changes in a pull request
50+
51+
Technically, there are at least two common ways to ask for changes in a pull
52+
request.
53+
54+
Either in the comment field of the pull request:
55+
:::{figure} img/code-review/comment.png
56+
:width: 60%
57+
:class: with-border
58+
:alt: Screenshot of a pull request comment field
59+
::::
60+
61+
Or by using the "Review changes":
62+
:::{figure} img/code-review/files-changed.png
63+
:width: 100%
64+
:class: with-border
65+
:alt: Screenshot of a pull request navigating to the "Review changes" tab
66+
::::
67+
68+
And always please be kind and constructive in your comments. Remember that the
69+
goal is not gate-keeping but **collaborative learning**.
70+
71+
72+
### How to suggest a change in a pull request as a reviewer
73+
74+
If you see a very small problem that is easy to fix, you can suggest a change
75+
as a reviewer.
76+
77+
Instead of asking the submitter to tiny problem, you can suggest a change by
78+
clicking on the plus sign next to the line number in the "Files changed" tab:
79+
:::{figure} img/code-review/leave-comment.png
80+
:width: 100%
81+
:class: with-border
82+
:alt: Screenshot of leaving a comment to a line in a pull request
83+
::::
84+
85+
Here you can comment on specific lines or even line ranges.
86+
87+
But now the interesting part is to click on the "Add a suggestion" symbol (the
88+
one that looks like plus and minus). Now you can fix the tiny problem (in this
89+
case a typo) and then click on the "Add single comment" button:
90+
:::{figure} img/code-review/add-suggestion.png
91+
:width: 60%
92+
:class: with-border
93+
:alt: Sequence of clicks to add a suggestion to a line in a pull request
94+
::::
95+
96+
The result is this and the submitter can accept the change with a single click:
97+
:::{figure} img/code-review/commit-suggestion.png
98+
:width: 60%
99+
:class: with-border
100+
:alt: Screenshot of a pull request with a suggested change
101+
::::
102+
103+
After accepting with "Commit suggestion", the improvement gets added to the
104+
pull request.
105+
106+
107+
### How to modify a pull request to address the review comments
108+
109+
If the reviewer asks for changes, it is not necessary to close the pull request
110+
and later open a new one. It can even be counter-productive to do so: This can
111+
fragment the discussion and the history of the pull request and can make it
112+
harder to understand the context of the changes.
113+
114+
A much better mechanism to recognize that pull requests are not implemented
115+
from a specific commit to a specific branch, but **always from a branch to a
116+
branch**.
117+
118+
This means that you can make amendments to the pull request by adding new
119+
commits to the same source branch. This way the pull request will be updated
120+
automatically and the reviewer can see the new changes and comment on them.
121+
122+
The fact that pull requests are from branch to branch also strongly suggests
123+
that it is a good practice to create a new branch for each pull request.
124+
Otherwise you could accidentally modify an open pull request by adding new
125+
commits to the source branch.
30.3 KB
Loading
87.7 KB
Loading
39 KB
Loading
66.9 KB
Loading
52.9 KB
Loading

0 commit comments

Comments
 (0)