CodeBlanks Logo Icon CodeBlanks

Required review

Learn the required review rule.

What Is a Required Review?

You can require a pull request to be reviewed by another team member before it is merged. On GitHub, this rule prevents changes from being merged into a protected branch until the required number of approvals is received. This allows code changes to be checked by another person.

main:
  required_approvals: 1

It helps identify mistakes early, especially in team projects.

Approval and Review Policy

You can specify how many approvals are needed in a required review rule. For example, required_approvals: 1 requires at least one approval. GitHub also does not count the pull request author's own approval as a valid team approval.

pull_request:
  required_approvals: 1
  dismiss_stale_reviews: true

The dismiss_stale_reviews option makes previous approvals invalid when new commits are pushed after the review.

Practice Require Two Approvals

Configure a pull request review policy for the main branch. Set required_approvals to 2 and set dismiss_stale_reviews to true to invalidate previous approvals when new commits arrive.

Starter code

terminal
# İnceleme politikası oluştur
# Gerekli onay sayısını belirle
# Eski onayları geçersiz kıl

Sample solution

terminal
main:
  pull_request:
    required_approvals: 2
    dismiss_stale_reviews: true

Expected output

İki onay zorunlu hale getirildi.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which value should be used if at least two team members must approve a pull request before it is merged?

  • required_approvals: 2 Correct answer
  • required_approvals: 0
  • required_approvals: 1
  • required_approvals: false

Explanation: When two separate approvals are required, the <code>required_approvals</code> value is set to 2.

2 Dismiss Previous Approvals

Question
pull_request:
  required_approvals: 1
  ____: true
Answer
pull_request:
  required_approvals: 1
  dismiss_stale_reviews: true

Explanation: <code>dismiss_stale_reviews</code> is used to invalidate previous reviews when new commits are pushed.

3 Review Rules

Term Meaning
Approval Approval given to a change
required_approvals Required number of approvals
dismiss_stale_reviews Dismisses outdated approvals
Pull request yazarı Cannot count their own approval

All lessons in Advanced