mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-07 21:37:02 +09:00
DROID-162 Editor | Tech | Add commit message checker (#2405)
This commit is contained in:
parent
09044cc5fb
commit
7c37cf4420
4 changed files with 57 additions and 0 deletions
28
.githooks/commit-msg
Executable file
28
.githooks/commit-msg
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
# The script below adds the branch name automatically to
|
||||
# every one of your commit messages. The regular expression
|
||||
# below searches for JIRA issue key's. The issue key will
|
||||
# be extracted out of your branch name
|
||||
|
||||
REGEX_ISSUE_ID="[a-zA-Z0-9,\.\_\-]+-[0-9]+"
|
||||
|
||||
# Find current branch name
|
||||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_TEXT=$(cat "$COMMIT_MSG_FILE")
|
||||
|
||||
if [[ -z "$BRANCH_NAME" ]]; then
|
||||
echo "Commit message validation failed: no branch name!"; exit 1
|
||||
fi
|
||||
|
||||
# Extract issue id from branch name
|
||||
ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID" | awk '{print toupper($0)}')
|
||||
|
||||
if [[ "$ISSUE_ID" != "DROID-"* ]]; then
|
||||
echo "Commit message validation failed: branch name should contain issue name!"; exit 1
|
||||
fi
|
||||
|
||||
if [[ "$COMMIT_TEXT" != "DROID-"* ]]; then
|
||||
echo "$ISSUE_ID " > "$COMMIT_MSG_FILE"
|
||||
echo "$COMMIT_TEXT" >> "$COMMIT_MSG_FILE"
|
||||
fi
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.idea/*
|
||||
!.idea/codeStyles
|
||||
!.idea/vcs.xml
|
||||
!.idea/copyright
|
||||
*.iml
|
||||
.gradle
|
||||
|
|
16
.idea/vcs.xml
generated
Normal file
16
.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="IssueNavigationConfiguration">
|
||||
<option name="links">
|
||||
<list>
|
||||
<IssueNavigationLink>
|
||||
<option name="issueRegexp" value="([A-Za-z]+)-(\d+)" />
|
||||
<option name="linkRegexp" value="https://linear.app/anytype/issue/$1-$2" />
|
||||
</IssueNavigationLink>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
12
build.gradle
12
build.gradle
|
@ -56,3 +56,15 @@ subprojects {
|
|||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
tasks.register("installGitHooks") {
|
||||
setGroup("Build Setup")
|
||||
setDescription("Install local repository git hooks")
|
||||
exec {
|
||||
commandLine 'sh', '-c', 'git config core.hooksPath .githooks'
|
||||
}
|
||||
}
|
||||
|
||||
var initialTaskNames = getProject().getGradle().getStartParameter().getTaskNames()
|
||||
getProject().getGradle().getStartParameter().setTaskNames(
|
||||
initialTaskNames + Collections.singletonList("installGitHooks"))
|
Loading…
Add table
Add a link
Reference in a new issue