Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure improvements #2

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .git-hooks/commit-msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

commit_pattern="### What's done:"
error_msg="Your commit message doesn't match the pattern $commit_pattern. Please fix it."

if [[ ! $( cat "$1" ) =~ $commit_pattern ]]
then
echo "$error_msg"
exit 1
fi

exit 0
13 changes: 13 additions & 0 deletions .git-hooks/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

branch_name="$(git rev-parse --abbrev-ref HEAD)"
branch_pattern="^(feature|bugfix|hotfix|infra)/.*$"
error_message="Your branch name doesn't match the pattern $branch_pattern. Please correct it before committing."

if [[ ! $branch_name =~ $branch_pattern ]]
then
echo "$error_message"
exit 1
fi

exit 0
27 changes: 0 additions & 27 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Kotlin slack ktlint channel
url: https://kotlinlang.slack.com/archives/CKS3XG0LS
about: Please ask and answer questions here.
- name: Telegram chat @diktat_kotlin
url: https://t.me/joinchat/AAAAAFDg-ipuZFGyBGPPeg
about: Ask everything about diktat in this channel
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Which rule and warnings did you add?

<!-- Briefly describe rule and warnings -->

## Actions checklist
* [ ] Implemented Rule, added Warnings
* [ ] Added tests on checks
* [ ] Added tests on fixers
* [ ] Updated rules-config.json
* [ ] Updated Readme

## Fixme

<!-- Is there anything left out of scope of this PR? -->
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ That's why we added logic for:

## How to build the project
As Java/Kotlin community has a holywar about usage of Gradle vs Maven - we supported both. So you can:

a) Use Maven:
`mvn clean install`

This will also install git hooks into your local .git directory. The hooks will restrict commit messages and branch naming.

b) Use Gradle:
`gradle build`

To install git hooks using gradle run `gradle installGitHooks`.

## Which rules does diKTat supports now and how they can be configured.
|Rule name|Description|
| ---- | ---- |
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ tasks.register("publishNewRelease", DefaultTask.class) {
description = "Triggers uploading new archives and publish announcements"
dependsOn announceTask
}

tasks.register("installGitHooks", Copy.class) {
from("$rootDir/.git-hooks/commit-msg.sh", "$rootDir/.git-hooks/pre-commit.sh")
into("$rootDir/.git/hooks")
rename("(.+).sh", '$1')
fileMode 0755
}
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,31 @@
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>com.rudikershaw.gitbuildhook</groupId>
<artifactId>git-build-hook-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<installHooks>
<!-- The location of a git hook to install into the default hooks directory. -->
<pre-commit>.git-hooks/pre-commit.sh</pre-commit>
<commit-msg>.git-hooks/commit-msg.sh</commit-msg>
</installHooks>
</configuration>
<executions>
<execution>
<id>install-git-hooks</id>
<phase>initialize</phase>
<goals>
<!-- Install specific hooks directly to the default hooks directory. -->
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>