|
| 1 | +.. _gh_dev_init: |
| 2 | + |
| 3 | +Beginning a Github Development |
| 4 | +============================== |
| 5 | + |
| 6 | +This section will guide you through the development process assuming you are already authorised with github (:ref:`gh_authorisation`) and have already created a fork (:ref:`forking`). |
| 7 | + |
| 8 | +Create an Issue |
| 9 | +--------------- |
| 10 | + |
| 11 | +.. important:: |
| 12 | + |
| 13 | + It is not guaranteed that opening an issue will result in action or even visibility by the relevant maintainers or code owners. If you think a team or individual should be aware of an issue, then contact them directly in addition to opening an issue. |
| 14 | + |
| 15 | +An issue in github can be used to document a problem in the codebase or as somewhere to document the development process for a new feature. Sub-issues can also be created if a large piece of work wants breaking down into smaller sections. If you are working on an issue, then assign yourself to it so that others know that you are working on it. Issues are created in the upstream repository. |
| 16 | + |
| 17 | +.. tab-set:: |
| 18 | + |
| 19 | + .. tab-item:: Web Browser |
| 20 | + |
| 21 | + Navigate to the ``Issues`` tab for the relevant **upstream** repo and select the ``New Issue``. Write an suitable title and description, and use the options on the right as desired/appropriate. |
| 22 | + |
| 23 | + .. image:: images/gh_screenshots/issues_light.png |
| 24 | + :class: only-light |
| 25 | + |
| 26 | + .. image:: images/gh_screenshots/issues_dark.png |
| 27 | + :class: only-dark |
| 28 | + |
| 29 | + .. tab-item:: gh cli |
| 30 | + |
| 31 | + The following command can be used to create an issue from the command line. The available options can be seen in the `gh cli documentation <https://cli.github.com/manual/gh_issue_create>`_. |
| 32 | + |
| 33 | + .. code-block:: |
| 34 | +
|
| 35 | + gh issue create -R <OWNER>/<REPO> [options] |
| 36 | +
|
| 37 | +There is no requirement to open an issue before making a pull request, as long as the change documentation is sufficient. For instance, small changes may not benefit from the separate issue. |
| 38 | + |
| 39 | + |
| 40 | +Clone the Repository |
| 41 | +-------------------- |
| 42 | + |
| 43 | +A clone is a local copy of a repository - you can have a local clone of either an upstream repository or a fork. A clone will have an active branch which will initially be the default branch of the repository. All other branches in the repository can be accessed using the ``checkout`` command (see below). For general development, you should now get a clone of your fork. |
| 44 | + |
| 45 | +.. tip:: |
| 46 | + |
| 47 | + For those familiar with svn/fcm, a clone is the git equivalent to a working copy. However, unlike a working copy, which can only access a single branch, a clone can be switched to any branch in the repository. |
| 48 | + |
| 49 | +.. tab-set:: |
| 50 | + |
| 51 | + .. tab-item:: git commands |
| 52 | + |
| 53 | + To clone a repository using git, run the following in a terminal: |
| 54 | + |
| 55 | + .. code-block:: |
| 56 | +
|
| 57 | + git clone <URL> <CLONE_NAME> |
| 58 | +
|
| 59 | + where ``CLONE_NAME`` is the desired directory name of the clone. It will default to the name of the repository. |
| 60 | + |
| 61 | + The ``URL`` can be found from github, |
| 62 | + |
| 63 | + .. image:: images/gh_screenshots/clone_button_light.png |
| 64 | + :class: only-light |
| 65 | + |
| 66 | + .. image:: images/gh_screenshots/clone_button_dark.png |
| 67 | + :class: only-dark |
| 68 | + |
| 69 | + selecting the url as desired. |
| 70 | + |
| 71 | + .. tab-item:: gh cli |
| 72 | + |
| 73 | + To clone a repository using gh cli run the following command, |
| 74 | + |
| 75 | + .. code-block:: |
| 76 | +
|
| 77 | + gh repo clone <OWNER>/<REPO> <CLONE_NAME> |
| 78 | +
|
| 79 | + where ``CLONE_NAME`` is the desired directory name of the clone. It will default to the name of the repository. |
| 80 | + |
| 81 | + .. tip:: |
| 82 | + |
| 83 | + Using gh cli to clone a fork will automatically add the upstream repository as a remote source which can be helpful. |
| 84 | + |
| 85 | + |
| 86 | +Create a Branch |
| 87 | +--------------- |
| 88 | + |
| 89 | +Branches for developing Simulation Systems repositories should generally be branched from ``stable`` where this exists (some smaller repositories only contain a ``main`` branch). Creating a branch from ``main`` may be acceptable if the development is continuing on from a ticket already committed at that release. |
| 90 | + |
| 91 | +To create a branch and switch to it from the command line, the syntax is, |
| 92 | + |
| 93 | +.. code-block:: |
| 94 | +
|
| 95 | + git branch <branch_name> <parent_branch> |
| 96 | + git checkout <branch_name> |
| 97 | +
|
| 98 | + # or |
| 99 | +
|
| 100 | + git checkout <parent_branch> |
| 101 | + git checkout -b <branch_name> |
| 102 | +
|
| 103 | +.. note:: |
| 104 | + |
| 105 | + It is also possible to create a new branch via github in a web browser. |
| 106 | + |
| 107 | + |
| 108 | +Developing a Change |
| 109 | +------------------- |
| 110 | + |
| 111 | +Now that you have a new branch, you are ready to begin development. See :ref:`development_index`, for advice on how to plan and implement new developments in a Simulation Systems repository, including advice on Metadata, KGO's and testing. |
| 112 | + |
| 113 | +.. tip:: |
| 114 | + |
| 115 | + To see the status of your current clone you can run ``git status`` |
| 116 | + |
| 117 | +While developing you will likely want to commit your changes and push to the remote repository. First you will need to stage any files that have been modified and you would like to include in your commit, |
| 118 | + |
| 119 | +.. code-block:: |
| 120 | +
|
| 121 | + git add path/to/file1 [path/to/file2...] |
| 122 | +
|
| 123 | +And then commit the change, |
| 124 | + |
| 125 | +.. code-block:: |
| 126 | +
|
| 127 | + git commit -m "An Informative Commit Message" |
| 128 | +
|
| 129 | +.. tip:: |
| 130 | + |
| 131 | + In git you do not need to commit all modified files unlike in svn/fcm. It is also possible to only commit certain parts of a modified file. For more information see the relevant man page, ``man git add``. |
| 132 | + |
| 133 | +Finally, you may want to push any commits stored in your local clone. |
| 134 | + |
| 135 | +.. code-block:: |
| 136 | +
|
| 137 | + git push |
| 138 | +
|
| 139 | +.. important:: |
| 140 | + |
| 141 | + Unlike svn/fcm, committing in git will not push your changes to the remote server. The ``git push`` command must also be used to do this. |
| 142 | + |
| 143 | + |
| 144 | + |
0 commit comments