First you will have to open te command line interface
(cli) in your fork's root.
The same way as described in the previous post when cloning the repository
(repo).
All commands that are available in the
studio script, start with
sh studio <command>
.
All commands that have parameters, the parameters are completely
optional!
Meaning that if you do not fill them in, you will be guided through the process when calling the bare command.
So you're explicitly asked what the parameter values should be for each parameter available.
If you were unable to save the script without a file extension and had to append
.sh
, you will have to append it in the command aswell.
Meaning that all the commands start with
sh studio.sh <command>
, but in the examples below we will use the first option.
The commands below are not listed in any particular order, but it's recommended to run the
setup
command first.
Especially cause this command only has to be ran once, and ensures you have to correct line endings setting.
Which is especially important if you are on Windows, which has a different default setting!
It is possible to get a list of available commands by only typing
sh studio
.
Overview
- Common commands
setup
update
switch
install (which I apparently forgot in the menu, sorry)
- Testing commands
test-pr
- Developing commands
create
commit
amend
clean
_____
______________________________________________________________________
setup
Command: sh studio setup
Parameters: "Name" "Email"
(both optional)
Example: sh studio setup mrgoldy [email protected]
Explanation:
This command should only have to be ran once, but it is not required for the rest of the
studio script to work.
The config settings that are set are the following:
Your git's
user.name
. If you do not provide any, it will not be set or overwritten. (
phpBB Docs and
reference)
Your git's
user.email
. If you do not provide any, it will not be set or overwritten. (
phpBB Docs and
reference)
Set git's
core.autocrlf
to
false
as per phpBB requirements. (
phpBB Docs and
reference)
Add
upstream as a remote, if it didn't exist already. (
phpBB Docs and
reference)
origin: This remote name is commonly used for your personal repository (
https://github.com/mrgoldy/phpbb.git).
upstream: This remote name is commonly used for the original repository (
https://github.com/phpbb/phpbb.git).
update
Command: sh studio update
Parameters: none
Example: sh studio update
Explanation:
Changes made to the phpBB GitHub repository (
https://github.com/phpbb/phpbb) are
not automatically made to your fork and clone.
Your
fork is your repository on GitHub (
https://github.com/mrgoldy/phpbb).
Your
clone are the files on your computer (
C:\xampp\htdocs\phpbbfork
).
So it is important that those stay up-to-date with any changes made to phpBB's repository, and you will have to do that yourself.
This can be done with the
sh studio update
command.
First it
pulls everything from the phpBB repository, so your
clone is updated.
Then it
pushes your clone, so your
fork is updated.
switch
Command: sh studio switch
Parameters: "Branch"
(optional) (3.2.x
|3.3.x
|master
)
Example: sh studio switch 3.2.x
|
sh studio switch 3.3.x
|
sh studio switch master
Explanation:
Currently there are three 'base' branches in phpBB:
master,
3.3.x and
3.2.x
These hold the code for their respective latest version,
at the time of writing:
4.0.0-a1
,
3.3.0
and
3.2.9
Each branch has its own code, database setup and dependencies (the
vendor
folder).
This command takes care of the code and dependencies, for the database setup you will have to use the
install
command.
Once done, it will automatically ask you if you also want to install the board, which you can answer with
Y
es or
N
o.
For the people interested in what is exactly doing:
git checkout master; git checkout <branch>; cd phpBB; php composer.phar install; cd ../
(
phpBB Docs and
reference)
install
Command: sh studio install
Parameters: none
Example: sh studio install
Explanation:
This will take care of the 'database setup' of your local board.
It ensures all the correct tables are installed, with the correct columns and default values.
For this command the
$phpbb_functional_url
is required in the
test_config.php file.
This ensures that we can
re-install the board, overriding an existing installation.
To accomplish this, the
studio script makes use of the
functional tests provided by phpBB,
which do not have to be of further concern to you for the sake of using the
studio script.
The credentials for the admin account on the local board are:
username: admin
password: adminadmin
_____
______________________________________________________________________
test-pr
Command: sh studio test-pr
Parameters: "PR number"
(optional)
Example: sh studio test-pr 5920
Explanation:
Now if actual code development is not your cup of tea, that does not mean you can not contribute!
You can head over to the
phpBB's Pull Request list and choose a PR you want to test.
If you click on one of the PR's, you can see the Pull Request number (the identifier) in the url bar of your browser.
For example, the url will be:
https://github.com/phpbb/phpbb/pull/5920
.
Then the identifier of that Pull Request, the PR number, will be
5920.
It will then automatically install the dependencies for that PR (the
vendor
folder).
Once done, it will automatically ask you if you also want to install the board, which you can answer with
Y
es or
N
o.
You will now be in a
"detached HEAD" state. Git will also post a notice about it
(before the dependencies message).
This will also be visible in the command line, cause it now displays
((7149349e25...)).
This isn't really to any concern to you and nothing for you to worry about.
But to quickly and simply explain it: it means that git does not recognize what branch you are on and is not sure what to do with it.
Once you are done testing or want to perform any different commands, use
git switch -
.
This will switch you back to the state your local
clone was in before testing.
You might notice the
((7149349e25...)) has changed back to
(master) (or what branch you were on).
Please do note that the installed board and its dependencies are
not automatically reverted back.
_____
______________________________________________________________________
Let's quickly talk a little bit about how all of this works.
The phpBB repository on GitHub contains all the current code, that is actually redistributed.
You do not have permission to alter any of the code directly, for obvious reasons.
So in order to still make changes to phpBB's code, you've created a copy: your
fork.
You can now make any changes you want to that code, and then propose them as a Pull Request.
You will have to perform these changes on your local
clone of your fork
(the files on your computer).
You will then have to
commit these changes (as a simple word: "save").
But then the changes are only done locally, on your computer, and are not yet on your fork.
So you will have to
push the changes from your clone to your fork (as a simple word: "upload").
Once your fork contains the changes aswell, you can compare that against the phpBB repository: the PR.
You can read more about all of this in the
phpBB Git Documenation.
create
Command: sh studio create
Parameters: "Base branch" "Ticket number"
(both optional)
Example: sh studio create 3.2.x 12345
Explanation:
phpBB has made it so, that changes made by anyone are not directly made on a branch, eg 3.2.x.
If that were the case, it would become harder to track who made which changes for what reason.
So first there has to be a ticket in the
phpBB Tracker, which allows for some oversight.
Once a ticket has been created, eg. for a bug or a feature, you will also know the
"Ticket number".
As an example, recently this ticket has been created:
phpBB 3 / PHPBB3-16426.
The number for this specific ticket is:
16426.
Then you will have to decide to what version this ticket belongs, is it aimed for 3.2.x, 3.3.x or master (4.0.0-a1)?
As a rule of thumb (at the time of writing) you can use:
master: New features
3.3.x: Bug fixes and minor improvements
3.2.x: Bug fixes
Once you know the "base branch" and the "ticket number", you can go ahead a create a branch.
This branch as to be created from the correct base branch, and follow a naming convention:
ticket/16426
.
The
sh studio create
command does all of this for you, to ensure you have the correct setup.
commit
Command: sh studio commit
Parameters: "Commit message"
(optional)
Example: sh studio commit "Implement new array syntax for UCP"
Explanation:
Make sure when making changes, that you are on the correct
ticket branch, created with
sh studio create
.
If you have made changes to your local files, you will have to "save" and "upload" them to your repository.
The git terms for these actions are
commit and
push respectively.
This command will automatically save any changes made to
existing files in your clone.
However, if you've created any
new files, these are not automatically added and git is not aware of them.
This is where TortoiseGit or any other tool is convenient, so you can more easily add extra files to the repository.
Alternatively you can use the git command:
git add <the file path>
.
For example, if we wanted to add
(the already existing) config.php:
git add phpBB/config.php
.
The path is relative to the root directory of your clone, the directory where this
studio script should be located.
Now, when saving these changes, you have to provide a required "
commit message".
Commit messages should also follow a precise layout, for all the automated actions tied to commits to work.
You can compare this to the
"edit reason" when editing a post in phpBB.
This command handles the layout of the commit message, you only have to provide a meaningful and concise reason.
The reason you provide should try and quickly explain what it is you're changing, with no more than 64 characters!
Once done, this command deducts the ticket number from the branch you are on, eg
ticket/16426
:
16426.
It then
commits and
pushes
("save" & "upload") your changes with the following commit message:
Code: Select all
[ticket/16426] Add default setting for search character limit
PHPBB3-16426
Afterwards, it will explain how you can create a Pull Request.
It will also ask you if you want to create a Pull Request right away, which you can answer with
Y
es or
N
o.
If you do want to create a PR, it will open a new browser tab from where you can create it.
It will automatically have to correct base branch selected, you only have to edit the PR template (the message).
amend
Command: sh studio amend
Parameters: "New commit message"
(optional)
Example: sh studio amend "My new commit message"
Explanation:
If you've made all your commits using the
studio script, you will probably not need this command.
It is more a situational and conveniene command, that allows to alter the last commit message.
For example, when you have an error in there that made the tests fail.
Make sure you are on one of your ticket branches, eg
ticket/16426
.
This command will then display your last commit message, and ask what the new one should be.
Once again, you only have to provide the 'reason', the rest of the commit message is automatically created.
clean
Command: sh studio clean
Parameters: none
Example: sh studio clean
Explanation:
This command is for convenience aswell, and not required to be ran once at all.
But it might be useful for some, especially once you've racked up quite a few Pull Requests.
Your fork and clone will then have a lot of ticket branches, which might already be merged into the phpBB repository.
These branches are no longer of any use and can savely be removed from your own repository.
This command will delete all the merged branches both in your clone and in your fork.
Note: the first time you run this, it might show a few git errors, due to the fact that your clone and fork might be out of sync.
For example, if you already deleted the ticket branch on your fork, but not on your clone.
_____
______________________________________________________________________
The end
These are all the currently available command in the
studio script!
We hope it helps out anyone willing to contribute in any way, shape or form.
If you have any suggestions, tips or notes about the script or this topic, feel free to post a reply!
Happy contributing,
The Studio