Skip to content

Commit 22fd798

Browse files
authored
Merge branch 'main' into add-troubleshooting-document
2 parents 6121740 + fb7f9a0 commit 22fd798

File tree

9 files changed

+380
-190
lines changed

9 files changed

+380
-190
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: How To Checkout and Commit to a PR from a Forked Repository
3+
category: Developer > Getting Started
4+
---
5+
6+
Contributors who are part of the Submitty organization on Github can
7+
make new branches on our Github repositories and should make PRs from
8+
a *branch directly within the Submitty repository*. External
9+
contributors cannot make new branches on the Submitty repositories.
10+
Instead, external contributors will clone/fork the Submitty repository
11+
and then make a PR from *a branch on their forked repository*.
12+
13+
It is simpler to review a PR made from a branch, and it is easy to
14+
make small revisions as needed and commit and push those changes to
15+
the branch. It is a little more work to do the same with a PR made
16+
from a fork, but it is still possible -- *assuming that the owner of
17+
the forked repository has granted the necessary permissions*. This
18+
allows multiple developers to collaborate and finalize a PR for
19+
merging to the main branch.
20+
21+
If you use Github Desktop or have the Github CLI installed, the simplest
22+
way to work on a fork is to click the **Code** dropdown on the PR's page
23+
on Github and checkout the PR from there.
24+
25+
![alt text](/images/fork-checkout.png)
26+
27+
The instructions below are for command line use of git.
28+
29+
1. **Before** you begin, confirm that your local main branch of Submitty is
30+
up-to-date. Additionally, if the PR's branch is not up-to-date with Submitty's main,
31+
there will be a button on its page on Github that you can press to update it.
32+
You may need to resolve merge conflicts in the process of updating it.
33+
34+
![alt text](/images/update-branch.png)
35+
36+
2. From the PR on the Github website, find the name of the
37+
user + branch name. It should be formatted something like this:
38+
```
39+
contributorusername:contributor_branch_name
40+
```
41+
42+
Additionally, find the name of the fork on the fork's page on Github.
43+
The `fork_name` may simply be `Submitty`, or the author may have chosen to another name.
44+
45+
46+
3. Next, make a local branch on your computer in your working repository
47+
with the proposed code changes. Here are the command lines
48+
(substitute the user, branch, and fork names we found above):
49+
50+
If you **are not** using ssh keys on git:
51+
```
52+
git checkout -b contributorusername-contributor_branch_name main
53+
git pull https://github.com/contributorusername/fork_name.git contributor_branch_name
54+
```
55+
56+
If you **are** using ssh keys on git:
57+
```
58+
git checkout -b contributorusername-contributor_branch_name main
59+
git pull [email protected]:contributorusername/fork_name.git contributor_branch_name
60+
```
61+
62+
63+
4. This has made a local branch named
64+
`contributorusername-contributor_branch_name`. Go ahead and test
65+
and review the PR and make code edits and new commits to your
66+
local branch as needed.
67+
68+
69+
70+
5. In order to push the changes to the contributor's fork (and the PR
71+
on Github from the fork), you will specify the upstream to be the
72+
contributor's fork:
73+
74+
If you **are not** using ssh keys on git:
75+
```
76+
git remote add upstream https://github.com/contributorusername/fork_name.git
77+
```
78+
79+
80+
If you **are** using ssh keys on git:
81+
```
82+
git remote add upstream [email protected]:contributorusername/fork_name.git
83+
```
84+
85+
86+
Confirm that the upstream was set:
87+
```
88+
git remote -v
89+
```
90+
91+
Which should print something like this if you **are not** using ssh keys on git:
92+
```
93+
origin https://github.com/Submitty/Submitty.git (fetch)
94+
origin https://github.com/Submitty/Submitty.git (push)
95+
upstream https://github.com/contributorusername/fork_name.git (fetch)
96+
upstream https://github.com/contributorusername/fork_name.git (push)
97+
```
98+
99+
Or this if you **are** using ssh keys on git:
100+
```
101+
origin [email protected]:Submitty/Submitty.git (fetch)
102+
origin [email protected]:Submitty/Submitty.git (push)
103+
upstream [email protected]:contributorusername/fork_name.git (fetch)
104+
upstream [email protected]:contributorusername/fork_name.git (push)
105+
```
106+
107+
108+
6. Now once you are finished with your code changes, first commit them to
109+
the local branch (named
110+
`contributorusername-contributor_branch_name`).
111+
112+
And then push them from your local branch to the external
113+
contributor's fork and update the PR on github:
114+
```
115+
git push upstream contributorusername-contributor_branch_name:contributor_branch_name
116+
```
117+
118+
*NOTE: If you encounter a permissions error, it is possible that the external
119+
contributor didn't grant access for collaboration on the branch.*
120+
121+
7. Confirm that you can see the changes on the Github website for the PR.
122+
123+
124+
---
125+
126+
See also [How to Make a Pull Request](make_a_pull_request) and
127+
[How to Review a Pull Request](review_a_pull_request).

_docs/developer/getting_started/make_a_pull_request.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Be sure to read the [Suggestions for New Developers](/developer/getting_started/
1818

1919

2020
2. Contributors from outside the Submitty GitHub organization should
21-
clone the repo on their own GitHub page, and create a branch with
21+
clone/fork the repo on their own GitHub page, and create a branch with
2222
the modifications to be included with this pull request (PR).
2323

2424
_**IMPORTANT NOTE**:_ Please grant write access to the Submitty
@@ -167,8 +167,11 @@ Be sure to read the [Suggestions for New Developers](/developer/getting_started/
167167
for specific reviewers.
168168
169169
170+
---
171+
170172
See also [How to Review a Pull Request](review_a_pull_request).
171173
174+
---
172175
173176
These guidelines drawn from:
174177

_docs/developer/getting_started/phpstorm.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Under the `Mappings` tab, set the following:
5151
This step will configure PhpStorm to use the PHP CLI that is configured inside your vagrant machine.
5252
It is important to use this PHP installation as opposed to some other one as it ensures environment consistency among developers and production servers.
5353

54-
Under PhpStorm settings, open `Languages & Frameworks` > `PHP`. Press the `...` button next to `CLI Interpreter` and, on the left list of the interpreters window, press the `+` and select `From Docker, Vagrant, VM, Remote...`.
54+
Under PhpStorm settings, open `PHP`. Press the `...` button next to `CLI Interpreter` and, on the left list of the interpreters window, press the `+` and select `From Docker, Vagrant, VM, Remote...`.
5555
Select `Vagrant` from the list of radio buttons.
5656
Then press `OK` to add the interpreter and `OK` to save the list of interpreters.
5757

@@ -61,7 +61,7 @@ Open `Tools` > `Deployment...` > `Options`. Set `Upload changed files automatica
6161

6262
## Enable PHP debugging using xdebug
6363

64-
Under PhpStorm settings, open `Languages & Frameworks` > `PHP` > `Debug`. In the pre-configuration steps, press `Validate` to open the configuration validator. Choose `Remote Web Server` and set the following:
64+
Under PhpStorm settings, open `PHP` > `Debug`. In the pre-configuration steps, press `Validate` to open the configuration validator. Choose `Remote Web Server` and set the following:
6565

6666
- `Path to create validation script`: `<submitty repository root>/site/public`
6767
- `Deployment Server`: Use the SFTP connection you set up in the first step
@@ -91,7 +91,7 @@ Now you can browse the tables in the database window by expanding the tabs next
9191

9292
## Running PHPUnit tests
9393

94-
Under PhpStorm settings, open `Languages & Frameworks` > `PHP` > `Test Frameworks`. Press the `+` button to add a testing configuration, using the `PHPUnit by Remote Interpreter` type. Choose the interpreter you configured in earlier steps. Then set:
94+
Under PhpStorm settings, open `PHP` > `Test Frameworks`. Press the `+` button to add a testing configuration, using the `PHPUnit by Remote Interpreter` type. Choose the interpreter you configured in earlier steps. Then set:
9595

9696
- `PHPUnit Library`: `Use Composer autoloader`
9797
- `Path to script`: `/usr/local/submitty/GIT_CHECKOUT/Submitty/site/vendor/autoloader.php`
@@ -132,7 +132,7 @@ Press `OK` to save the run configuration. If you then `Debug` the configuration,
132132

133133
During debugging, you may get decently upset at how often you step into magic methods and class loaders etc. There's an easy fix for this:
134134

135-
Under PhpStorm settings, open `Languages & Frameworks` > `PHP` > `Debug` > `Step Filters`. Check `Skip magic methods` and add the following to `Skipped Methods`:
135+
Under PhpStorm settings, open `PHP` > `Debug` > `Step Filters`. Check `Skip magic methods` and add the following to `Skipped Methods`:
136136

137137
- `app\views\AbstractView->__construct`
138138
- `app\models\AbstractModel->convertName`

_docs/developer/getting_started/review_a_pull_request.md

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ What do you need to do?
5353
Now you have a version of the code in a new branch on the main repo.
5454
Review the PR normally and delete the temporary branch when you are done
5555
56+
* If you need to make edits to a PR made from a branch in a forked
57+
repo, see:
58+
[How to Checkout and Commit to a Fork PR](commit_to_PR_from_fork)
59+
5660
5761
4. [Re-install the system](/developer/development_instructions/index)
5862
as necessary
@@ -108,5 +112,6 @@ What do you need to do?
108112
hopefully, in short order, approving that the code be merged into
109113
the main branch.
110114
115+
---
111116
112117
See also [How to Make a Pull Request](make_a_pull_request).

0 commit comments

Comments
 (0)