1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
|
Maintainer Notes
================
This is for those with read-write access to upstream. It is recommended to name
the upstream remote something to remind you that it is read-write::
git remote add upstream-rw git@github.com:statsmodels/statsmodels.git
git fetch upstream-rw
Git Workflow
------------
Grabbing Changes from Others
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you need to push changes from others, you can link to their repository by doing::
git remote add contrib-name git://github.com/contrib-name/statsmodels.git
get fetch contrib-name
git branch shiny-new-feature --track contrib-name/shiny-new-feature
git checkout shiny-new-feature
The rest of the below assumes you are on your or someone else's branch with the changes you
want to push upstream.
.. _rebasing:
Rebasing
^^^^^^^^
If there are only a few commits, you can rebase to keep a linear history::
git fetch upstream-rw
git rebase upstream-rw/main
Rebasing will not automatically close the pull request however, if there is one,
so do not forget to do this.
.. _merging:
Merging
^^^^^^^
If there is a long series of related commits, then you'll want to merge. You
may ask yourself, :ref:`ff-no-ff`? See below for more on this choice. Once
decided you can do::
git fetch upstream-rw
git merge --no-ff upstream-rw/main
Merging will automatically close the pull request on github.
Check the History
^^^^^^^^^^^^^^^^^
This is very important. Again, any and all fixes should be made locally before
pushing to the repository::
git log --oneline --graph
This shows the history in a compact way of the current branch. This::
git log -p upstream-rw/main..
shows the log of commits excluding those that can be reached from
upstream-rw/main, and including those that can be reached from current HEAD.
That is, those changes unique to this branch versus upstream-rw/main. See
:ref:`Pydagogue <pydagogue:git-log-dots>` for more on using dots with log and
also for using :ref:`dots with diff <pydagogue:git-diff-dots>`.
Push Your Feature Branch
^^^^^^^^^^^^^^^^^^^^^^^^
All the changes look good? You can push your feature branch after
:ref:`merging` or :ref:`rebasing` by::
git push upstream-rw shiny-new-feature:main
Cherry-Picking
^^^^^^^^^^^^^^
Say you are interested in some commit in another branch, but want to leave the
other ones for now. You can do this with a cherry-pick. Use `git log --oneline`
to find the commit that you want to cherry-pick. Say you want commit `dd9ff35`
from the `shiny-new-feature` branch. You want to apply this commit to main.
You simply do::
git checkout main
git cherry-pick dd9ff35
And that's all. This commit is now applied as a new commit in main.
.. _ff-no-ff:
Merging: To Fast-Forward or Not To Fast-Forward
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, `git merge` is a fast-forward merge. What does this mean, and when
do you want to avoid this?
.. figure:: images/git_merge.png
:alt: git merge diagram
:scale: 100%
:align: center
(source `nvie.com <http://nvie.com>`__, post `"A successful Git branching model" <http://nvie.com/posts/a-successful-git-branching-model/>`__)
The fast-forward merge does not create a merge commit. This means that the
existence of the feature branch is lost in the history. The fast-forward is the
default for Git basically because branches are cheap and, therefore, *usually*
short-lived. If on the other hand, you have a long-lived feature branch or are
following an iterative workflow on the feature branch (i.e. merge into main,
then go back to feature branch and add more commits), then it makes sense to
include only the merge in the main branch, rather than all the intermediate
commits of the feature branch, so you should use::
git merge --no-ff
Handling Pull Requests
^^^^^^^^^^^^^^^^^^^^^^
You can apply a pull request through `fetch <https://www.kernel.org/pub/software/scm/git/docs/git-fetch.html>`__
and `merge <https://www.kernel.org/pub/software/scm/git/docs/git-merge.html>`__.
In your local copy of the main repo::
git checkout main
git remote add contrib-name git://github.com/contrib-name/statsmodels.git
git fetch contrib-name
git merge contrib-name/shiny-new-feature
Check that the merge applies cleanly and the history looks good. Edit the merge
message. Add a short explanation of what the branch did along with a
'Closes gh-XXX.' string. This will auto-close the pull request and link the
ticket and closing commit. To automatically close the issue, you can use any
of::
gh-XXX
GH-XXX
#XXX
in the commit message. Any and all problems need to be taken care of locally
before doing::
git push origin main
Releasing
---------
1. Checkout main::
git checkout statsmodels/main
2. Clean the working tree with::
git clean -xdf
But you might want to do a dry-run first::
git clean -xdfn
3. **Locally** tag the release. For a release candidate, for example::
git tag -a v0.10.0rc1 -m "Version 0.10.0 Release Candidate 1" 7b2fb29
or just::
git tag -a v0.10.0rc1 -m "Version 0.10.0 Release Candidate 1"
to use the last commit in main.
4. Checkout the tag::
git checkout tags/v0.10.0rc1
5. Build a sdist to ensure that that the build is clean::
python -m build --sdist .
It is important that the build on the tar.gz file is the same as the tag. It must not be **dirty**
6. If on a new minor release (major.minor.micro format) start a new maintenance branch, for example::
git checkout -b maintenance/0.10.x
Any bug fixes and maintenance commits intended for the next micro release should be made
against main as usual, but tagged with the milestone for the micro release it is intended
for. Then merge into main as usual. When ready to do the backports, use the file
``tools/backport_pr.py`` to identify which PRs need to be backported and to apply them to the
maintenance branch. The tag for the release should be made in the maintenance branch.
7. Upload the source distribution to PyPI::
twine upload dist/*
You might want to upload to test first::
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
8. Go back to the main branch, and add an empty commit::
git checkout statsmodels/main
git commit --allow-empty -m "Start of 0.11.0 development"
git tag -a v0.11.0.dev0 -m "Start of 0.11.0 development"
9. Push everything to statsmodels::
git push --tags
If a new branch was created::
git push --set-upstream origin maintenance/0.10.x
10. Make an announcement, and inform maintainers of wheel builders.
11. Profit?
Releasing from Maintenance Branch
---------------------------------
Once any patches have been backported to a maintenance branch, the release steps are
1. Checkout the branch::
git checkout maintenance/0.10.x
2. Clean up thoroughly::
git clean -xdf
3. **Locally** tag the release::
git tag -a v0.10.0 -m "Version 0.10.0"
4. Checkout the tag::
git checkout tags/v0.10.0
5. Build a sdist to ensure that that the build is clean::
python -m build --sdist .
It is important that the build on the tar.gz file is the same as the tag. It must not be **dirty**.
6. Upload the source distribution to PyPI ot PyPI test::
twine upload dist/*
or::
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
7. Push the tag to statsmodels::
git push --tags
8. Make an announcement, and inform maintainers of wheel builders.
Commit Comments
---------------
Prefix commit messages in the main branch of the main shared repository with
the following::
ENH: Feature implementation
BUG: Bug fix
STY: Coding style changes (indenting, braces, code cleanup)
DOC: Sphinx documentation, docstring, or comment changes
CMP: Compiled code issues, regenerating C code with Cython, etc.
REL: Release related commit
TST: Change to a test, adding a test. Only used if not directly related to a bug.
REF: Refactoring changes
|