Skip to content

Commit 731f58a

Browse files
committed
Add library code
1 parent a93ecb6 commit 731f58a

File tree

6 files changed

+1187
-2
lines changed

6 files changed

+1187
-2
lines changed

README.md

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,96 @@
1-
# gitChangeLog
2-
Generate a changelog from git commits of the local repository
1+
# gitChangelog
2+
3+
[![GitHub release](https://img.shields.io/github/v/release/DigiLive/gitChangelog?include_prereleases)](https://github.com/DigiLive/gitChangelog/releases)
4+
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
5+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7f0447563661494daac0c4fae4335ac0)](https://www.codacy.com/gh/DigiLive/gitChangelog/dashboard?utm_source=github.com&utm_medium=referral&utm_content=DigiLive/gitChangelog&utm_campaign=Badge_Grade)
6+
7+
Generate a changelog from git commits of the local repository.
8+
9+
This library parses information which is stored in the Git directory in which it is currently located. With this
10+
information, it generates a changelog which can be saved into a file.
11+
12+
Check out this [example](CHANGELOG.md) which is actually the changelog of this repository.
13+
14+
If you have any questions, comments or ideas concerning this library, Please consult
15+
the [Wiki](https://github.com/DigiLive/gitChangelog/wiki) at first. Create a
16+
new [issue](https://github.com/DigiLive/gitChangeLog/issues/new) is your concerns remain unanswered.
17+
18+
## Features
19+
20+
### Main
21+
22+
- List Tags and their date.
23+
- List unique commit subjects per tag/release.
24+
- List commit hashes per unique subject (optional).
25+
- Include commit subjects (and hashes) of the HEAD revision (E.g. Unreleased changes).
26+
- Append the content of another file (E.g. An already existing changelog).
27+
- Save the content of the (appended) changelog to file.
28+
29+
### Other
30+
31+
- Set a From- and To tag to limit the changelog.
32+
- Filter subjects by labels.
33+
- Set a header for the changelog (E.g. a title).
34+
- Set a custom subject for the HEAD revision.
35+
- Set a custom date for the HEAD revision (E.g. Next Tag/Release date).
36+
- Set a custom message to indicate there are no commits present.
37+
- In- or exclude merge commits.
38+
- Define a custom format for Tag/Release lines.
39+
- Define a custom format for subject lines.
40+
- Define a custom format for hash lines.
41+
42+
### Planned
43+
44+
- Allow sorting tags by other keys than creator date.
45+
- Allow sorting subjects by labels.
46+
- Set sort order of tags and subjects.
47+
48+
## Installation
49+
50+
The preferred method is to install the library with [Composer](http://getcomposer.org).
51+
52+
```sh
53+
> composer require digilive/git-changelog:^1
54+
```
55+
56+
Alternatively you can download the latest release from [Github](https://github.com/DigiLive/gitChangelog/releases).
57+
58+
## Example use
59+
60+
```php
61+
<?php
62+
63+
use DigiLive\GitChangeLog\GitChangeLog;
64+
65+
// Instantiate composer's auto loader.
66+
require __DIR__ . '/../vendor/autoload.php';
67+
68+
// Or include the library manually.
69+
// require_once 'Path/To/GitChangeLog.php';
70+
71+
// Instantiate the library.
72+
$changelog = new GitChangeLog();
73+
// Build and save the changelog with all defaults.
74+
$changelog->build();
75+
$changelog->save('CHANGELOG.md');
76+
```
77+
78+
## Notes
79+
80+
- Most settings can be changed directly by setting a public property.
81+
**(Setting a value of an invalid type, might result in unexpected results.)**
82+
- The From- and To tags, have to be set by calling a method, because they're validated.
83+
- Labels must be set by methods also to avoid overhead when adding the same label multiple times.
84+
85+
## Commit guidelines
86+
87+
In order to suitable a good changelog, you should follow the following guidelines:
88+
89+
- Commit messages must have a subject line and may have body copy.
90+
These must be separated by a blank line.
91+
- The subject line must not exceed 50 characters.
92+
- The subject line should be capitalized and must not end in a period.
93+
- The subject line must be written in an imperative mood (Fix, not Fixed / Fixes etc.).
94+
- The body copy must be wrapped at 72 columns.
95+
- The body copy must only contain explanations as to what and why, never how. The latter belongs in documentation and
96+
implementation.

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "digilive/git-changelog",
3+
"description": "Generate a changelog from git commits of the local repository",
4+
"keywords": [
5+
"php",
6+
"git",
7+
"changelog",
8+
"generator"
9+
],
10+
"type": "library",
11+
"minimum-stability": "stable",
12+
"license": "BSD-3-Clause",
13+
"authors": [
14+
{
15+
"name": "DigiLive",
16+
"email": "info@digilive.nl",
17+
"homepage": "https://digilive.nl"
18+
},
19+
{
20+
"name": "Mario",
21+
"email": "leet31337@web.de"
22+
}
23+
],
24+
"require": {
25+
"php": "^7.2"
26+
},
27+
"require-dev": {
28+
"phpunit/phpunit": "^9",
29+
"mikey179/vfsstream": "^1.6"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"DigiLive\\GitChangeLog\\": "src/",
34+
"DigiLive\\GitChangeLog\\Tests\\": "tests/"
35+
}
36+
}
37+
}

phpunit.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ BSD 3-Clause License
4+
~
5+
~ Copyright (c) 2020, Ferry Cools (DigiLive)
6+
~ All rights reserved.
7+
~
8+
~ Redistribution and use in source and binary forms, with or without
9+
~ modification, are permitted provided that the following conditions are met:
10+
~
11+
~ 1. Redistributions of source code must retain the above copyright notice, this
12+
~ list of conditions and the following disclaimer.
13+
~
14+
~ 2. Redistributions in binary form must reproduce the above copyright notice,
15+
~ this list of conditions and the following disclaimer in the documentation
16+
~ and/or other materials provided with the distribution.
17+
~
18+
~ 3. Neither the name of the copyright holder nor the names of its
19+
~ contributors may be used to endorse or promote products derived from
20+
~ this software without specific prior written permission.
21+
~
22+
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
~ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
~ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
~ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
~ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
~ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
~ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
~
33+
-->
34+
35+
<phpunit bootstrap="tests/bootstrap.php">
36+
<testsuites>
37+
<testsuite name="GitChangeLog">
38+
<directory>tests</directory>
39+
</testsuite>
40+
</testsuites>
41+
<filter>
42+
<whitelist processUncoveredFilesFromWhitelist="true">
43+
<directory suffix=".php">src</directory>
44+
</whitelist>
45+
</filter>
46+
</phpunit>

0 commit comments

Comments
 (0)