Участник:Novaepee/sandbox: различия между версиями

Материал из MassMeta
Перейти к навигации Перейти к поиску
imported>Novaepee
imported>Novaepee
Строка 114: Строка 114:
If your master version is out of date, the branch will change color. You now must pull to apply those new changes to your master (In this example, the master branch is 3 commits behind upstream master).
If your master version is out of date, the branch will change color. You now must pull to apply those new changes to your master (In this example, the master branch is 3 commits behind upstream master).


[[center]]
[[File:TGMC_bravemole_contributing_guidePicture15.png|center]]
   
   
'''Never make changes to the master branch'''
'''Never make changes to the master branch'''
Строка 120: Строка 120:
Every time you want to make a modification to the code, you must first make a new branch.
Every time you want to make a modification to the code, you must first make a new branch.


[[center]]
[[File:TGMC_bravemole_contributing_guidePicture16.png|center]]


Make sure you are making a branch from master, if you are not, click on the arrow pointing to the left to chose which branch to branch out.  
Make sure you are making a branch from master, if you are not, click on the arrow pointing to the left to chose which branch to branch out.  


[[center]]
[[File:TGMC_bravemole_contributing_guidePicture17.png|center]]
   
   
Name your branch, press enter.
Name your branch, press enter.


[[center]]
[[File:TGMC_bravemole_contributing_guidePicture18.png|center]]


Create branch and switch on it.
Create branch and switch on it.
Строка 134: Строка 134:
Switching to a branch means your modification will apply to this branch and not the others. You can always switch to another branch by right clicking on it in the branch menu.
Switching to a branch means your modification will apply to this branch and not the others. You can always switch to another branch by right clicking on it in the branch menu.


[[center]]
[[File:TGMC_bravemole_contributing_guidePicture19.png|center]]


You can now make changes to the code!
You can now make changes to the code!

Версия от 23:26, 2 декабря 2021

Sandbox time

Nice!

Guide to contributing made by Bravemole.

Файл:DMCA Logo.png This page is a part of the TGMC wiki.

TGMC is a project based on the CM-SS13 codebase.


 
The New "Coder" говорит:
"Hey, I want to put in this feature that will revolutionized the game! So where do I start?"

You poor, poor soul.

Let’s get you on your way to contributing. This isn’t the guide for hardcore coders. This is for the guy who just wants a thing tweaked. If you’re really into making big feature changes, talk in the #Dev-General channel and get the people there to help you.

Prerequisite

Your own TGMC fork

Once you are connected on github, go to https://github.com/tgstation/TerraGov-Marine-Corps and click on fork.

This will give you your own copy of the TGMC code, where you test your stuff without interfering with the common repository.

Cloning the code

Go to your repositories in GitHub and click on TGMC.

You want to copy the HTTPS address of your fork, so click on code, then HTTPS and copy the link.

That’s everything we needed to do on the GitHub side, let’s switch to VSC (Visual studio code).

This should be the starting window on VSC, click on clone git repository, paste the repo link on the command line that appeared, and press enter.

It will ask you where to save the cloned files, so choose whatever folder you want (like My documents, or whatever).

If for some reason you don’t have clone git repo in the start menu, you need to open a new terminal, and type git clone the_url like so:

The files will be saved in C:\user\bsouchu in this exemple.

After the cloning, click on open folder and find where the files were saved.

Needed extensions

Now that you have access to your private version of the code, you need some VSC extensions to be able work on the code properly.

Go to extensions, then type @recommended in the search bar, and install everything there (Note: the list might change).

Reboot your VSC so all the changes are considered.

Adding the public remote

A remote is a git repository. In VSC, you want to have access to your private fork (which we will name here origin) to make changes to your version to the code, but also have access to the common public repo (the upstream) so you can pull the latest version of the code (AKA, always have the updated version).

Go to source control, remote, this should look like this:

And we want to add the upstream remote:

You now have access to the public repo, let’s get the master branch from it (use the right click on master, chose switch to branch):

And name it master upstream.

This should look like something like this, click on the star to make it your preferred branch so it’s always at the top:

You then want to delete your master branch that is coming from origin (Never ever use this master, you ONLY need the master from upstream).

So right click on master, Delete Branch.

Rename your master_upstream to master, right click on master upstream, rename Branch.

Making modification to the code

You first want to make modification on the latest version of the code; having an outdated code means you’re surely have merge conflicts as soon as your PR is opened, which is pain.

You want to fetch (ask what the updates are) on the master branch (this is the upstream one, so it will directly fetch the latest server code version).

If your master version is out of date, the branch will change color. You now must pull to apply those new changes to your master (In this example, the master branch is 3 commits behind upstream master).

Never make changes to the master branch

Every time you want to make a modification to the code, you must first make a new branch.

Make sure you are making a branch from master, if you are not, click on the arrow pointing to the left to chose which branch to branch out.

Name your branch, press enter.

Create branch and switch on it.

Switching to a branch means your modification will apply to this branch and not the others. You can always switch to another branch by right clicking on it in the branch menu.

You can now make changes to the code!

Let’s say I want to make the tp44 fire with a 2 second delay (nerfing the revolver is a tradition on TGMC). Let’s go to revolvers.dm (Use the shortcut CTRL-e, then type revolver, then chose the guns/revolvers.dm one.)

Do your changes and hit CTRL-s to save the file.

Testing your code

You can now test your modifications. That is very easy, you just need to hit F5! (or got to run and debug and click this button).

center

This will compile (the first compilation takes some time) and automatically launch the game; you’ll be able to join/observe with full access to admin/host powers.

With VSC come a very powerful debugger which allows access to all variables of the call stack (if you don’t understand those terms, that’s fine). Just keep in mind that if the game freezes, it’s not a crash; it’s a runtime, AKA an error/exception. To resume the game from such a freeze, you must go back to VSC and use the control panel.

Hit the resume button (not present on this screenshot).

center

Once you are happy with your tests, it’s time to make the PR.

Committing, publishing, and making a pull request

You’ll notice a blue 1 on source control, this means that you have a changed file that was not committed to the branch (A commit is like a snapshot of your code in a branch at a given moment, you can go back and forth between commits like you can go back and forth between branches).

center

Type a sensible commit message and commit your changes:

center

Note that it is a very good habit to commit every time you made a consequent change. If your PR is adding 3 features, it’s maybe a good idea to have 3 commits. That way, if your 2 first features are working but the third is breaking everything, you can go back to a version where at least 2 features are working.

After that, you want to publish your branch (aka, put your branch on the internet).

center

And push on origin. You can now go to https://github.com/tgstation/TerraGov-Marine-Corps/pulls and make a PR (pull request)

center

Fill out the pull request form, don’t forget to have a proper changelog:

center

Hit pull request, and voilà! You’re done.

center

It will also appear in the #github channel on discord:

center

The github server is now making some test on your code:

center

If something is red, click on it to look at what the error is.

Push modifications to a pull request

Maintainers will now be able to review your pull request. Be patient, this make takes a while, a pinging them will not result in a faster review.

If your PR has review requests, or if you just want to make changes to it, you just need to make new commits and push them.

center

center