Skip to content

Instantly share code, notes, and snippets.

@aiKrice
aiKrice / Add_badge.sh
Created October 6, 2024 09:18
Create badges for Pull Request
#!/bin/bash
//Github gh client
//Need GH_TOKEN or GITHUB_TOKEN exported
//BITRISE_PULL_REQUEST = ID of PR
//BITRISEIO_GIT_BRANCH_DEST = Branch against the PR is opened
//BITRISE_BUILD_URL = link of the current pipeline build
// JIRA ID is extract from this pattern from the title : ...(APPS-123455) or ...(BUG-123455)...
pull_request_body=$(gh pr view $BITRISE_PULL_REQUEST --json body -q '.body')
@aiKrice
aiKrice / medium-commit-msg.sh
Created June 15, 2024 21:28
Medium commit msg
#! /bin/zsh
source "githooks/android/toolbox.sh"
hook="Commit-msg check"
progress "$hook"
if [[ "$commit_message" =~ $conventionnal_commit_pattern ]]; then
exitWithMessage "$hook failed because it doesn't match to your convention"
else
@aiKrice
aiKrice / medium-prepare-commit.sh
Created June 15, 2024 21:27
Medium prepare-commit-msg
#! /bin/zsh
source "githooks/android/toolbox.sh"
hook="Prepare-commit-msg check"
progress "$hook"
COMMIT_EDITMSG=$1
commit_message=$(cat $COMMIT_EDITMSG)
char_count=$(echo $commit_message | wc -m)
@aiKrice
aiKrice / Medium-pre-commit.sh
Last active June 15, 2024 21:26
Medium pre-commit
#! /bin/zsh
source "githooks/android/toolbox.sh"
hook="Pre-commit check"
progress "$hook"
if [ ! -z "$stagedKotlinFiles" ]; then
#run autoformatter
progress "Autoreformatting the code..."
@aiKrice
aiKrice / Dangerfile.rb
Last active May 19, 2024 16:28
Dangerfile Swiftlint + baseline support
#Swiftlint
swiftlint.config_file = "#{ENV['BITRISE_SOURCE_DIR']}/.swiftlint.yml"
swiftlint.binary_path = "/opt/homebrew/bin/swiftlint" #to speed up you CI
swiftlint.strict = true
swiftlint.verbose = true
#swiftlint.filter_issues_in_diff = true #optional now because the baseline support it 🎉
swiftlint.lint_files(inline_mode: true, additional_swiftlint_args: "--baseline #{ENV['BITRISE_SOURCE_DIR']}/path/to/baseline.json")
@aiKrice
aiKrice / pre-commit.sh
Created May 19, 2024 15:31
pre-commit hook with baseline
#!/bin/sh
# Get Swift files that are staged
staged_files=$(git diff --cached --name-only --diff-filter=d | grep ".swift$")
# Check if we have any Swift files to format
if [[ "$staged_files" = "" ]]; then
echo "swiftlint skipped: No source files to lint."
exit 0
fi
@aiKrice
aiKrice / swiftlint-baseline-xcode.sh
Created May 19, 2024 15:06
Xcode build phase running with baseline
#!/bin/sh
#filter unstaged swift files
unstaged_swift_files_relative=$(git status --porcelain | grep -e '^[^\sD]' | grep '\.swift$' | cut -c4- | grep -v '^githooks/')
#filter staged swift files
staged_swift_files_relative=$(git diff --cached --name-only --diff-filter=d | grep '\.swift$' | grep -v '^githooks/')
#Removed duplication with both staged and unstaged files
all_swift_files=$(echo "$staged_swift_files_relative" "$unstaged_swift_files_relative" | sort | uniq)
@aiKrice
aiKrice / pre-commit.sh
Created February 25, 2024 21:10
AndroidLint + terminal-notifier: pre-commit
#!/bin/sh
# Get kotlin files that are staged
staged_files=$(git diff --cached --name-only --diff-filter=d | grep ".kt$")
# Check if we have didn't edit any souce files
if [[ "$staged_files" = "" ]]; then
echo "AndroidLint skipped: No source files to format."
exit 0
fi
@aiKrice
aiKrice / pre-commit.sh
Created February 25, 2024 21:04
AndroidLint: pre-commit
#!/bin/sh
# Get kotlin files that are staged
staged_files=$(git diff --cached --name-only --diff-filter=d | grep ".kt$")
# Check if we have any Kotlin files to format
if [[ "$staged_files" = "" ]]; then
echo "Android lint skipped: No source files to format."
exit 0
fi
@aiKrice
aiKrice / pre-commit.sh
Last active February 25, 2024 20:57
Detekt: pre-commit
#!/bin/sh
# Get kotlin files that are staged
staged_files=$(git diff --cached --name-only --diff-filter=d | grep ".kt$")
# Check if we have any Kotlin files to lint
if [[ "$staged_files" = "" ]]; then
echo "Detekt skipped: No source files to lint."
exit 0
fi