Skip to content

Commit 91cfa2f

Browse files
committed
Merge branch 'develop'
2 parents ded619e + 6172799 commit 91cfa2f

34 files changed

+961
-129
lines changed

.editorconfig

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ ij_formatter_tags_enabled = true
1818
ij_smart_tabs = false
1919
ij_visual_guides =
2020
ij_wrap_on_typing = false
21+
ktlint_ignore_back_ticked_identifier = false
22+
ktlint_function_naming_ignore_when_annotated_with = unset
23+
ktlint_function_signature_body_expression_wrapping = multiline
24+
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
2125

2226
[*.css]
2327
ij_css_align_closing_brace_with_properties = false
@@ -157,7 +161,7 @@ ij_java_for_statement_wrap = off
157161
ij_java_generate_final_locals = false
158162
ij_java_generate_final_parameters = false
159163
ij_java_if_brace_force = never
160-
ij_java_imports_layout = *,|,javax.**,java.**,|,$*
164+
ij_java_imports_layout = com.codejsha.**,|,*,|,java.**,javax.**,|,$*
161165
ij_java_indent_case_from_switch = true
162166
ij_java_insert_inner_class_imports = false
163167
ij_java_insert_override_annotation = true
@@ -171,10 +175,10 @@ ij_java_keep_first_column_comment = false
171175
ij_java_keep_indents_on_empty_lines = false
172176
ij_java_keep_line_breaks = true
173177
ij_java_keep_multiple_expressions_in_one_line = false
174-
ij_java_keep_simple_blocks_in_one_line = false
175-
ij_java_keep_simple_classes_in_one_line = false
176-
ij_java_keep_simple_lambdas_in_one_line = false
177-
ij_java_keep_simple_methods_in_one_line = false
178+
ij_java_keep_simple_blocks_in_one_line = true
179+
ij_java_keep_simple_classes_in_one_line = true
180+
ij_java_keep_simple_lambdas_in_one_line = true
181+
ij_java_keep_simple_methods_in_one_line = true
178182
ij_java_label_indent_absolute = false
179183
ij_java_label_indent_size = 0
180184
ij_java_lambda_brace_style = end_of_line
@@ -1088,7 +1092,7 @@ ij_groovy_ginq_on_wrap_policy = 1
10881092
ij_groovy_ginq_space_after_keyword = true
10891093
ij_groovy_if_brace_force = never
10901094
ij_groovy_import_annotation_wrap = 2
1091-
ij_groovy_imports_layout = *,|,javax.**,java.**,|,$*
1095+
ij_groovy_imports_layout = com.codejsha.**,|,*,|,java.**,javax.**,|,$*
10921096
ij_groovy_indent_case_from_switch = true
10931097
ij_groovy_indent_label_blocks = true
10941098
ij_groovy_insert_inner_class_imports = false
@@ -1286,6 +1290,7 @@ ij_go_wrap_func_result_newline_before_rparen = true
12861290

12871291
[{*.graphqlconfig,*.graphqlrc,*.har,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,.ws-context,bowerrc,jest.config}]
12881292
ij_json_indent_size = 2
1293+
ij_json_continuation_indent_size = 4
12891294
ij_json_array_wrapping = split_into_lines
12901295
ij_json_keep_blank_lines_in_code = 0
12911296
ij_json_keep_indents_on_empty_lines = false
@@ -1326,7 +1331,7 @@ ij_html_quote_style = double
13261331
ij_html_remove_new_line_before_tags = br
13271332
ij_html_space_after_tag_name = false
13281333
ij_html_space_around_equality_in_attribute = false
1329-
ij_html_space_inside_empty_tag = false
1334+
ij_html_space_inside_empty_tag = true
13301335
ij_html_text_wrap = normal
13311336

13321337
[{*.http,*.rest}]
@@ -1379,7 +1384,7 @@ ij_kotlin_field_annotation_wrap = split_into_lines
13791384
ij_kotlin_finally_on_new_line = false
13801385
ij_kotlin_if_rparen_on_new_line = true
13811386
ij_kotlin_import_nested_classes = false
1382-
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
1387+
ij_kotlin_imports_layout = com.codejsha.**,|,*,|,java.**,javax.**,kotlin.**,^
13831388
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
13841389
ij_kotlin_keep_blank_lines_before_right_brace = 0
13851390
ij_kotlin_keep_blank_lines_in_code = 1

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
* text=auto
22

3+
*.bat text eol=crlf
4+
*.cmd text eol=crlf
5+
*.ps1 text eol=crlf
36
*.sh text eol=lf
47
*.svg text
58
*.txt text eol=lf

cpp/editorconfig/.editorconfig renamed to cpp/editorconfig/.cpp.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: APACHE-2.0
22
# SPDX-FileCopyrightText: Copyright 2023-2024 Jinseong Ha
33

4-
### Microsoft Visual Studio
4+
### EditorConfig Settings for Microsoft Visual Studio C++
55

66
root = true
77

cpp/editorconfig/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

git/git-commands.sh

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ GIT_TRACE=1 git push origin main
4343

4444
######################################################################
4545

46-
git clone <REPO_URL>
47-
git clone --recurse-submodules <REPO_URL>
46+
### config
4847

49-
function git-clone-lower() { REPO_URL="${1}"; DIR_NAME="${2}"; if [ -n "${DIR_NAME}" ]; then REPO_NAME="${DIR_NAME}"; else REPO_NAME=$(basename "${REPO_URL}" .git | tr '[:upper:]' '[:lower:]'); fi; echo "+ git clone ${REPO_URL} ${REPO_NAME}">&2; command git clone ${REPO_URL} ${REPO_NAME}; }
48+
git config --global --list
49+
git config --local --list
50+
git config --list
51+
52+
git config user.name developer
53+
git config user.email [email protected]
5054

5155
######################################################################
5256

@@ -67,6 +71,8 @@ git push -u origin main
6771
######################################################################
6872

6973
### repo
74+
75+
### initialize
7076
git init
7177

7278
### remote
@@ -78,21 +84,6 @@ git remote set-url origin http://git.example.com/developer/my-app-cd.git
7884
### submodule
7985
git submodule add https://github.com/codejsha/infrastructure-examples infrastructure
8086

81-
######################################################################
82-
83-
### config
84-
85-
git config --global --list
86-
git config --local --list
87-
git config --list
88-
89-
git config user.name developer
90-
git config user.email [email protected]
91-
92-
######################################################################
93-
94-
### collaborate
95-
9687
### fetch
9788
git fetch --all
9889

@@ -105,6 +96,11 @@ git push origin main
10596
git push --force origin main
10697
git push --no-verify
10798

99+
### clone
100+
git clone <REPO_URL>
101+
git clone --recurse-submodules <REPO_URL>
102+
function git-clone-lower() { REPO_URL="${1}"; DIR_NAME="${2}"; if [ -n "${DIR_NAME}" ]; then REPO_NAME="${DIR_NAME}"; else REPO_NAME=$(basename "${REPO_URL}" .git | tr '[:upper:]' '[:lower:]'); fi; echo "+ git clone ${REPO_URL} ${REPO_NAME}">&2; command git clone ${REPO_URL} ${REPO_NAME}; }
103+
108104
######################################################################
109105

110106
### add

git/hooks/pre-commit

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
trap 'echo "${BASH_SOURCE[0]}: line ${LINENO}: status ${?}: user ${USER}: func ${FUNCNAME[0]}"' ERR
33
set -o errexit
44
set -o errtrace
@@ -14,8 +14,7 @@ echo "[INFO] Repository root: ${REPO_ROOT}"
1414

1515
######################################################################
1616

17-
### Block specific keywords
18-
17+
### block specific keywords
1918
BLOCKED_KEYWORDS="$(cat ${HOOKS_DIR}/blocked_keywords.txt)"
2019
for KEYWORD in ${BLOCKED_KEYWORDS}; do
2120
if git diff --cached | grep ${KEYWORD}; then
@@ -26,34 +25,58 @@ done
2625

2726
######################################################################
2827

29-
### Signing commits
28+
### signing commits
3029

3130
CURRENT_USER_NAME="$(git config user.name)"
3231
CURRENT_USER_EMAIL="$(git config user.email)"
3332
CURRENT_GPG_SIGNING_KEY="$(git config user.signingkey)"
3433

35-
### Check if the current GPG signing key exists
34+
### check if the current gpg signing key exists
3635
if [ -z "${CURRENT_GPG_SIGNING_KEY}" ]; then
3736
echo "[ERROR] No GPG key set for signing commits."
3837
exit 1
3938
fi
39+
echo "[pre-commit] [INFO] Current GPG signing key: ${CURRENT_GPG_SIGNING_KEY}"
4040

41-
### Check if the current user name and email match the env config
41+
### check if the current user name and email match the env config
4242
if [ "${CURRENT_USER_NAME}" != "${ENV_USER_NAME}" ] ||
4343
[ "${CURRENT_USER_EMAIL}" != "${ENV_USER_EMAIL}" ]; then
4444
echo "[ERROR] Commit rejected. Your user name or email is incorrect."
4545
exit 1
4646
fi
47+
echo "[pre-commit] [INFO] Current user name: ${CURRENT_USER_NAME}"
48+
echo "[pre-commit] [INFO] Current user email: ${CURRENT_USER_EMAIL}"
4749

50+
### check if the current gpg signing key matches the env config
4851
GPG_USER_INFO="$(gpg --list-keys --with-colons "${ENV_GPG_SIGNING_KEY}" | grep "^uid:" | head -n 1 | cut -d: -f10)"
4952
GPG_USER_NAME="${GPG_USER_INFO% <*}"
5053
GPG_USER_EMAIL="${GPG_USER_INFO#*<}" && GPG_USER_EMAIL="${GPG_USER_EMAIL%>}"
51-
52-
### Check if the current GPG signing key matches the env config
5354
if [ "${CURRENT_USER_NAME}" != "${GPG_USER_NAME}" ] ||
5455
[ "${CURRENT_USER_EMAIL}" != "${GPG_USER_EMAIL}" ]; then
5556
echo "[ERROR] Git config user name or email doesn't match the GPG key's user name or email."
5657
exit 1
5758
fi
59+
echo "[pre-commit] [INFO] GPG signing key matches the environment config."
60+
61+
######################################################################
62+
63+
### execute formatting
64+
65+
### format kotlin files
66+
git diff --cached --name-only --diff-filter=ACM | rg '\.kt$|\.kts$' | while read -r FILE; do
67+
echo "[pre-commit] [INFO] Formatting file: ${FILE}"
68+
ktlint -F --editorconfig ${HOME}/properties/config/.editorconfig "${REPO_ROOT}/${FILE}"
69+
git add "${REPO_ROOT}/${FILE}"
70+
done
71+
72+
### format golang files
73+
git diff --cached --name-only --diff-filter=ACM | rg '\.go$' | while read -r FILE; do
74+
echo "[pre-commit] [INFO] Formatting file: ${FILE}"
75+
gofmt -s -w ${REPO_ROOT}/${FILE}
76+
goimports -w ${REPO_ROOT}/${FILE}
77+
git add "${REPO_ROOT}/${FILE}"
78+
done
79+
80+
######################################################################
5881

5982
exit 0

git/hooks/pre-push

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
trap 'echo "${BASH_SOURCE[0]}: line ${LINENO}: status ${?}: user ${USER}: func ${FUNCNAME[0]}"' ERR
33
set -o errexit
44
set -o errtrace
@@ -14,39 +14,41 @@ echo "[INFO] Repository root: ${REPO_ROOT}"
1414

1515
######################################################################
1616

17+
### print commits to push
1718
COMMITS_TO_PUSH=""
1819
if [ -z "$(git ls-remote --heads origin)" ]; then
19-
### The remote repository is empty
20+
### the remote repository is empty
2021
COMMITS_TO_PUSH="$(git log --pretty=format:"%H")"
2122
else
2223
COMMITS_TO_PUSH="$(git log @{u}.. --pretty=format:"%H")"
2324
fi
2425
echo "[INFO] Commits to push:"
2526
echo "${COMMITS_TO_PUSH}"
2627

28+
######################################################################
29+
30+
### validate commits to push
2731
for COMMIT in ${COMMITS_TO_PUSH}; do
28-
### Check if the commit is GPG signed
29-
if [ ! -z $(git verify-commit ${COMMIT} > /dev/null 2>&1) ]; then
30-
echo "[ERROR] Commit ${COMMIT} is not GPG signed."
32+
### check if the commit is gpg signed
33+
if ! { git verify-commit ${COMMIT} > /dev/null 2>&1; }; then
34+
echo "[pre-push] [ERROR] Commit ${COMMIT} is not GPG signed."
3135
exit 1
3236
fi
3337

38+
### check if the commit user name and email match the env config
3439
COMMIT_USER_NAME="$(git show -s --pretty=format:%aN ${COMMIT})"
3540
COMMIT_USER_EMAIL="$(git show -s --pretty=format:%aE ${COMMIT})"
36-
37-
### Check if the commit user name and email match the env config
3841
if [ "${COMMIT_USER_NAME}" != "${ENV_USER_NAME}" ] ||
3942
[ "${COMMIT_USER_EMAIL}" != "${ENV_USER_EMAIL}" ]; then
4043
echo "[ERROR] Push rejected. Your user name or email is incorrect."
4144
exit 1
4245
fi
4346

47+
### check if the commit gpg signing key matches the env config
4448
COMMIT_GPG_SIGNING_KEY="$(git show -s --pretty=format:%GF ${COMMIT})"
4549
COMMIT_GPG_USER_INFO="$(git show -s --pretty=format:%GS ${COMMIT})"
4650
COMMIT_GPG_USER_NAME="${COMMIT_GPG_USER_INFO% <*}"
4751
COMMIT_GPG_USER_EMAIL="${COMMIT_GPG_USER_INFO#*<}" && COMMIT_GPG_USER_EMAIL="${COMMIT_GPG_USER_EMAIL%>}"
48-
49-
### Check if the commit GPG signing key matches the env config
5052
if [ "${COMMIT_GPG_SIGNING_KEY}" != "${ENV_GPG_SIGNING_KEY}" ]; then
5153
echo "[ERROR] Commit ${COMMIT} is signed with a different GPG key."
5254
exit 1

git/hooks/prepare-commit-msg

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,49 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
trap 'echo "${BASH_SOURCE[0]}: line ${LINENO}: status ${?}: user ${USER}: func ${FUNCNAME[0]}"' ERR
33
set -o errexit
44
set -o errtrace
55

6-
echo "[INFO] prepare-commit-msg hook"
7-
86
source ~/properties/git/hooks/.env
97
HOOKS_DIR=$(git rev-parse --git-path hooks)
108
REPO_ROOT=$(git rev-parse --show-toplevel)
11-
echo "[INFO] Environment: ${ENV_NAME}"
12-
echo "[INFO] Git hooks dir: ${HOOKS_DIR}"
13-
echo "[INFO] Repository root: ${REPO_ROOT}"
9+
echo "[pre-push] [INFO] environment: ${ENV_NAME}"
10+
echo "[pre-push] [INFO] git hooks dir: ${HOOKS_DIR}"
11+
echo "[pre-push] [INFO] repository root: ${REPO_ROOT}"
1412

1513
COMMIT_MSG_FILE=${1}
1614
COMMIT_SOURCE=${2}
1715

1816
######################################################################
1917

20-
### Print branch name
21-
if [ -z "$(git rev-parse --abbrev-ref HEAD > /dev/null 2>&1)" ]; then
22-
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
23-
echo "[INFO] Branch name: ${BRANCH_NAME}"
24-
fi
25-
26-
### Skip for merge, squash, and rebase
27-
echo "[INFO] Commit source: ${COMMIT_SOURCE}"
28-
if [ "${COMMIT_SOURCE}" = "merge" ] || [ "${COMMIT_SOURCE}" = "squash" ] ; then
29-
echo "[INFO] Skip for merge or squash commit."
30-
exit 0
31-
fi
32-
if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then
33-
echo "[INFO] Skip for rebase."
34-
exit 0
18+
### print branch name
19+
if git rev-parse --verify HEAD >/dev/null 2>&1; then
20+
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
21+
echo "[prepare-commit-msg] [INFO] Branch name: ${BRANCH_NAME}"
3522
fi
3623

3724
######################################################################
3825

39-
### Validate commit message
40-
echo "[INFO] Commit message: $(cat ${COMMIT_MSG_FILE})"
26+
### validate commit message
27+
28+
echo "[prepare-commit-msg] [INFO] Commit message: $(cat ${COMMIT_MSG_FILE})"
4129
COMMIT_MESSAGE="$(cat "${COMMIT_MSG_FILE}")"
4230

43-
if [ "${COMMIT_MESSAGE}" = "Initial commit" ]; then
44-
echo "[INFO] Skip for initial commit."
31+
if [ "${COMMIT_MESSAGE}" = "Initial commit" ] || [ "${COMMIT_MESSAGE}" = "initial commit" ]; then
32+
echo "[prepare-commit-msg] [INFO] Skip for initial commit."
4533
exit 0
4634
fi
4735

48-
COMMIT_MESSAGE_PATTERN="^(feat|fix|docs|style|refactor|chore|test|gitflow-feature-stash): .*$"
36+
COMMIT_MESSAGE_PATTERN="^(feat|fix|docs|style|refactor|chore|test|gitflow-feature-stash): .+|^Merge (branch|pull request).*$"
4937
if [[ -z "${COMMIT_MESSAGE}" ]]; then
50-
echo "[ERROR] Commit message cannot be empty."
38+
echo "[prepare-commit-msg] [ERROR] Commit message cannot be empty."
5139
exit 1
5240
fi
5341
if [[ ! "${COMMIT_MESSAGE}" =~ ${COMMIT_MESSAGE_PATTERN} ]]; then
54-
echo "[ERROR] Commit message must start with a commit type: feat|fix|docs|style|refactor|chore|test"
42+
echo "[prepare-commit-msg] [ERROR] Commit message must start with a commit type (feat|fix|docs|style|refactor|chore|test) or be a merge commit."
5543
exit 1
5644
fi
5745
if echo "${COMMIT_MESSAGE}" | grep -q -E "\s{2,}"; then
58-
echo "[ERROR] Commit message must not contain two spaces."
46+
echo "[prepare-commit-msg] [ERROR] Commit message must not contain two spaces."
5947
exit 1
6048
fi
6149

0 commit comments

Comments
 (0)