]> git.proxmox.com Git - libgit2.git/blame - CONTRIBUTING.md
New upstream version 0.27.0+dfsg.1
[libgit2.git] / CONTRIBUTING.md
CommitLineData
41b00ccc
BS
1# Welcome to libgit2!
2
3We're making it easy to do interesting things with git, and we'd love to have
4your help.
5
dcfdb977
BS
6## Licensing
7
68a19ca9
RB
8By contributing to libgit2, you agree to release your contribution under
9the terms of the license. Except for the `examples` directory, all code
10is released under the [GPL v2 with linking exception](COPYING).
11
12The `examples` code is governed by the
13[CC0 Public Domain Dedication](examples/COPYING), so that you may copy
14from them into your own application.
dcfdb977 15
41b00ccc
BS
16## Discussion & Chat
17
ac63149c
WP
18We hang out in the
19[`#libgit2`](http://webchat.freenode.net/?channels=#libgit2)) channel on
20irc.freenode.net.
41b00ccc 21
1631147c
RB
22Also, feel free to open an
23[Issue](https://github.com/libgit2/libgit2/issues/new) to start a discussion
24about any concerns you have. We like to use Issues for that so there is an
25easily accessible permanent record of the conversation.
26
a142ed91
RB
27## Libgit2 Versions
28
29The `master` branch is the main branch where development happens.
30Releases are tagged
b247a39d 31(e.g. [v0.21.0](https://github.com/libgit2/libgit2/releases/tag/v0.21.0) )
a142ed91
RB
32and when a critical bug fix needs to be backported, it will be done on a
33`<tag>-maint` maintenance branch.
34
41b00ccc
BS
35## Reporting Bugs
36
1631147c
RB
37First, know which version of libgit2 your problem is in and include it in
38your bug report. This can either be a tag (e.g.
ac63149c
WP
39[v0.17.0](https://github.com/libgit2/libgit2/releases/tag/v0.17.0)) or a
40commit SHA
41(e.g. [01be7863](https://github.com/libgit2/libgit2/commit/01be7863)).
42Using [`git describe`](http://git-scm.com/docs/git-describe) is a
a142ed91 43great way to tell us what version you're working with.
1631147c 44
a142ed91 45If you're not running against the latest `master` branch version,
1631147c
RB
46please compile and test against that to avoid re-reporting an issue that's
47already been fixed.
41b00ccc 48
1631147c
RB
49It's *incredibly* helpful to be able to reproduce the problem. Please
50include a list of steps, a bit of code, and/or a zipped repository (if
51possible). Note that some of the libgit2 developers are employees of
52GitHub, so if your repository is private, find us on IRC and we'll figure
53out a way to help you.
41b00ccc
BS
54
55## Pull Requests
56
09846fd1
ET
57Our work flow is a [typical GitHub
58flow](https://guides.github.com/introduction/flow/index.html), where
59contributors fork the [libgit2 repository](https://github.com/libgit2/libgit2),
a142ed91 60make their changes on branch, and submit a
09846fd1
ET
61[Pull Request](https://help.github.com/articles/using-pull-requests)
62(a.k.a. "PR"). Pull requests should usually be targeted at the `master`
63branch.
41b00ccc 64
1631147c 65Life will be a lot easier for you (and us) if you follow this pattern
a142ed91
RB
66(i.e. fork, named branch, submit PR). If you use your fork's `master`
67branch directly, things can get messy.
68
69Please include a nice description of your changes when you submit your PR;
70if we have to read the whole diff to figure out why you're contributing
71in the first place, you're less likely to get feedback and have your change
72merged in.
73
eae0bfdc
PP
74In addition to outlining your thought process in the PR's description, please
75also try to document it in your commits. We welcome it if every commit has a
76description of why you have been doing your changes alongside with your
77reasoning why this is a good idea. The messages shall be written in
78present-tense and in an imperative style (e.g. "Add feature foobar", not "Added
79feature foobar" or "Adding feature foobar"). Lines should be wrapped at 80
80characters so people with small screens are able to read the commit messages in
81their terminal without any problem.
82
83To make it easier to attribute commits to certain parts of our code base, we
84also prefer to have the commit subject be prefixed with a "scope". E.g. if you
85are changing code in our merging subsystem, make sure to prefix the subject with
86"merge:". The first word following the colon shall start with an lowercase
87letter. The maximum line length for the subject is 70 characters, preferably
88shorter.
89
a142ed91
RB
90If you are starting to work on a particular area, feel free to submit a PR
91that highlights your work in progress (and note in the PR title that it's
92not ready to merge). These early PRs are welcome and will help in getting
93visibility for your fix, allow others to comment early on the changes and
94also let others know that you are currently working on something.
1631147c 95
a142ed91 96Before wrapping up a PR, you should be sure to:
41b00ccc 97
09846fd1 98* Write tests to cover any functional changes
a142ed91
RB
99* Update documentation for any changed public APIs
100* Add to the [`CHANGELOG.md`](CHANGELOG.md) file describing any major changes
6ca83665 101
09846fd1
ET
102## Unit Tests
103
104We believe that our unit tests allow us to keep the quality of libgit2
105high: any new changes must not cause unit test failures, and new changes
106should include unit tests that cover the bug fixes or new features.
107For bug fixes, we prefer unit tests that illustrate the failure before
108the change, but pass with your changes.
109
110In addition to new tests, please ensure that your changes do not cause
111any other test failures. Running the entire test suite is helpful
112before you submit a pull request. When you build libgit2, the test
1308059d 113suite will also be built. You can run most of the tests by simply running
09846fd1
ET
114the resultant `libgit2_clar` binary. If you want to run a specific
115unit test, you can name it with the `-s` option. For example:
116
117 libgit2_clar -sstatus::worktree::long_filenames
118
119Or you can run an entire class of tests. For example, to run all the
120worktree status tests:
121
122 libgit2_clar -sstatus::worktree
123
1308059d
ET
124The default test run is fairly exhaustive, but it will exclude some
125unit tests by default: in particular, those that talk to network
126servers and the tests that manipulate the filesystem in onerous
127ways (and may need to have special privileges to run). To run the
128network tests:
129
130 libgit2_clar -ionline
131
132In addition, various tests may be enabled by environment variables,
133like the ones that write exceptionally large repositories or manipulate
134the filesystem structure in unexpected ways. These tests *may be
135dangerous* to run on a normal machine and may harm your filesystem. It's
136not recommended that you run these; instead, the continuous integration
137servers will run these (in a sandbox).
138
41b00ccc
BS
139## Porting Code From Other Open-Source Projects
140
1631147c
RB
141`libgit2` is licensed under the terms of the GPL v2 with a linking
142exception. Any code brought in must be compatible with those terms.
143
144The most common case is porting code from core Git. Git is a pure GPL
145project, which means that in order to port code to this project, we need the
146explicit permission of the author. Check the
41b00ccc 147[`git.git-authors`](https://github.com/libgit2/libgit2/blob/development/git.git-authors)
6ca83665 148file for authors who have already consented.
41b00ccc 149
1631147c
RB
150Other licenses have other requirements; check the license of the library
151you're porting code *from* to see what you need to do. As a general rule,
152MIT and BSD (3-clause) licenses are typically no problem. Apache 2.0
153license typically doesn't work due to GPL incompatibility.
41b00ccc 154
a142ed91
RB
155If your pull request uses code from core Git, another project, or code
156from a forum / Stack Overflow, then *please* flag this in your PR and make
157sure you've given proper credit to the original author in the code
158snippet.
6ca83665 159
1631147c 160## Style Guide
41b00ccc 161
68a19ca9
RB
162The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C)
163(a.k.a. C89) compatible. Internally, `libgit2` is written using a portable
72556cc6 164subset of C99 - in order to compile with GCC, Clang, MSVC, etc., we keep
68a19ca9
RB
165local variable declarations at the tops of blocks only and avoid `//` style
166comments. Additionally, `libgit2` follows some extra conventions for
167function and type naming, code formatting, and testing.
1631147c
RB
168
169We like to keep the source code consistent and easy to read. Maintaining
170this takes some discipline, but it's been more than worth it. Take a look
09846fd1
ET
171at the [conventions
172file](https://github.com/libgit2/libgit2/blob/development/CONVENTIONS.md).
41b00ccc 173
1631147c
RB
174## Starter Projects
175
09846fd1
ET
176See our [projects
177list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md).