Skip to content

Commit 0755ae0

Browse files
authored
Merge pull request #412 from DasSkelett/feature/branch-warning
Show a warning comment for PRs targeting the wrong base branch
2 parents da4ff97 + 59e5117 commit 0755ae0

File tree

3 files changed

+63
-29
lines changed

3 files changed

+63
-29
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Wrong base branch warning
2+
3+
on:
4+
# The pull_request_target trigger runs the workflow in the context of the base branch
5+
# which has security benefits and is enough for our purposes
6+
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request_target
7+
pull_request_target:
8+
types: [ opened ]
9+
10+
jobs:
11+
branch-warning:
12+
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
13+
if: (github.event.pull_request_target.base.label == 'KSP-SpaceDock:master'
14+
&& github.event.pull_request_target.head.label != 'KSP-SpaceDock:beta')
15+
|| (github.event.pull_request_target.base.label == 'KSP-SpaceDock:beta'
16+
&& github.event.pull_request_target.head.label != 'KSP-SpaceDock:alpha')
17+
runs-on: ubuntu-latest
18+
permissions:
19+
pull-requests: write
20+
steps:
21+
# https://docs.github.com/en/actions/managing-issues-and-pull-requests/commenting-on-an-issue-when-a-label-is-added
22+
- name: Trigger warning comment
23+
uses: peter-evans/create-or-update-comment@v1
24+
with:
25+
issue-number: ${{ github.event.pull_request_target.number }}
26+
body: |
27+
⚠️ Warning ⚠️ This pull request is targeting `${{ github.event.pull_request.base.ref }}`.
28+
New changes need to go to `alpha` first and will be merged to `beta` and `master` in batches, see [this section in our wiki](https://github.com/KSP-SpaceDock/SpaceDock/wiki/Development-Guide#branching-system).
29+
30+
You can change the target base of the pull request by clicking "Edit" next to the title and selecting `alpha` in the dropdown to the left.

CONTRIBUTING.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
GIT
2-
---
3-
Cloning
1+
## Getting started
42

5-
git clone https://github.com/KSP-SpaceDock/SpaceDock.git
3+
Please read the [Development Guide](https://github.com/KSP-SpaceDock/SpaceDock/wiki/Development-Guide).
4+
If you are interested in the infrastructure and production setup of SpaceDock, see [Infrastructure](https://github.com/KSP-SpaceDock/SpaceDock/wiki/Infrastructure).
65

7-
Updating
86

9-
git fetch --all
10-
git merge
7+
## GIT
118

12-
Contributing
13-
First you will need to fork "SpaceDock" on github, and set up your SSH key.
9+
### Setup
1410

15-
git remote rm origin
16-
git remote add upstream https://github.com/KSP-SpaceDock/SpaceDock.git
17-
git remote add origin git@github.com:YOUR_USER_NAME_HERE/SpaceDock.git
18-
git fetch --all
19-
git push --set-upstream origin master
11+
1) [Fork the repository on GitHub](https://guides.github.com/activities/forking/)
12+
2) Clone your fork: `git clone https://github.com/<YourUsername>/SpaceDock.git`
13+
3) Configure `git pull` to do fast-forward merges only: `git config --global pull.ff=only`
14+
4) Add the main repo as a remote: `git remote add upstream https://github.com/KSP-SpaceDock/SpaceDock.git`
15+
5) Get the alpha branch from the main repo: `git checkout -b alpha upstream/alpha`
2016

21-
Make a branch so you don't bork your master.
2217

23-
git branch bugfix-number
24-
git checkout bugfix-number
18+
### Adding changes
2519

26-
Do your changes here with your favourite text editor or IDE.
20+
1) First check out `alpha`: `git checkout alpha`
21+
2) Make sure it is up-to-date: `git pull upstream alpha`
22+
3) Create a new branch: `git checkout -b fix/<one-to-three-word-summary>`
23+
We tend to prefix our branch names with `fix/` for bugfixes and `feature/` for new features
24+
4) Do your changes here with your favourite text editor or IDE.
25+
5) Add your changes to the index: `git add <path/to/changed/file> <path/to/another/file>`
26+
Make sure you only add changes that you actually want to commit! `git commit -A` might include files you didn't want to.
27+
You can review your currently added changes with: `git diff --staged`
28+
6) Create a commit with the staged changes: `git commit -m "A small message about your commit`
29+
7) Push the changes to your GitHub fork: `git push --set-upstream origin fix/<one-to-three-word-summary>`
30+
8) Prepare a pull request on GitHub. If you open your fork on github.com it probably already shows you a button to do this.
31+
Enter a detailed summary into the PR body text box.
32+
Include your motivation for the feature, a way to reproduce the bug if possible, and other points that might be important or helpful for reviewers.
33+
Go through your diff one more time to make sure everything is included, do a "self-review".
2734

28-
git add -A
29-
git commit -a -m "A small message about your commit"
30-
git push --set-upstream origin bugfix-number
31-
32-
When you are happy with the code, open a pull request on github. After it is merged you can delete it and merge it in your master
33-
34-
git checkout master
35-
git fetch --all
36-
git merge upstream/master
37-
git branch -D bugfix-number
38-
git push origin :bugfix-number
35+
There are more extensive guides available at https://guides.github.com/, e.g.
36+
- https://github.com/git-guides
37+
- https://guides.github.com/introduction/git-handbook/
38+
- https://guides.github.com/introduction/flow/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Website engine for Kerbal Space Program mods.
44

55
https://spacedock.info
66

7+
## Contributing
8+
9+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md)
10+
711
## Installation
812

913
This describes a bare-metal setup. For a local development setup using Docker, see https://github.com/KSP-SpaceDock/SpaceDock/wiki/Development-Guide#running-with-docker.

0 commit comments

Comments
 (0)