Skip to content

Latest commit

 

History

History
437 lines (328 loc) · 7.01 KB

maskfile.md

File metadata and controls

437 lines (328 loc) · 7.01 KB

Tasks for human-rights.nvim

Using mask

fixgit

Delete .git\index.lock (Windows Only)

echo "Linux is not support!"
if (Test-Path .\.git\index.lock) {
    Remove-Item .\git\index.lock
}

patch

Create a patch and copy it to windows

mask clean
mask diff-patch
mask copy2win-patch
mask clean
mask diff-patch
mask copy2win-patch

gpg-patch

Create a GPG-encrypted patch and copy it to Windows

mask clean
mask diff-patch --gpg
mask copy2win-patch --gpg
mask clean
mask diff-patch --gpg
mask copy2win-patch --gpg

diff-patch

Create a patch

OPTIONS

  • gpg
    • flags: --gpg
    • desc: Use GPG encrypt
PRODUCT_NAME="human-rights.nvim"
DEFAULT_REMOTE="origin"
DEFAULT_BRANCH="master"
TODAY=$(date +'%Y%m%d')
BRANCH_NAME=$(git branch --show-current)
GPG_PUB_KEY="CCAA9E0638DF9088BB624BC37C0F8AD3FB3938FC"

if [[ "$BRANCH_NAME" = "$DEFAULT_BRANCH" ]] || [[ "$BRANCH_NAME" = "patch-"* ]]; then
    echo "This branch is $DEFAULT_BRANCH or patch branch"

    for p in "$PRODUCT_NAME" "." "$TODAY" "." "patch"; do
        PATCH_NAME+=$p
    done
else
    echo "This branch is uniq feat branch"

    for p in "$PRODUCT_NAME" "_" "$BRANCH_NAME" "." "$TODAY" "." "patch"; do
        PATCH_NAME+=$p
    done
fi

if [[ "$gpg" == "true" ]]; then
    GPG_PATCH_NAME+=$PATCH_NAME
    GPG_PATCH_NAME+=".gpg"
    echo "gpg patch file name: $GPG_PATCH_NAME"
    git diff "$DEFAULT_REMOTE/$DEFAULT_BRANCH" | gpg --encrypt --recipient "$GPG_PUB_KEY" >"$GPG_PATCH_NAME"
else
    echo "patch file name: $PATCH_NAME"
    git diff "$DEFAULT_REMOTE/$DEFAULT_BRANCH" >"$PATCH_NAME"
fi
param(
    $gpg = $env:gpg
)

$product_name = "human-rights.nvim"
$default_remote = "origin"
$default_branch = "master"
$today = Get-Date -UFormat '%Y%m%d'
$branch_name = (git branch --show-current)
$gpg_pub_key = "CCAA9E0638DF9088BB624BC37C0F8AD3FB3938FC"

if (($branch_name -eq $default_branch) -or ($branch_name -match "^patch-*")) {
    Write-Output "This branch is $default_branch or patch branch"
    $patch_name = "$product_name.$today.patch"
} else {
    $branch_name = $branch_name -replace "/", "-"

    Write-Output "This branch is uniq feat branch"
    $patch_name = "$product_name.$branch_name.$today.patch"
}

$TempMyOutputEncode=[System.Console]::OutputEncoding
[System.Console]::OutputEncoding=[System.Text.Encoding]::UTF8

if ($gpg) {
    $gpg_patch_name = "$patch_name.gpg"
    Write-Output "gpg patch file name: $gpg_patch_name"
    #git diff "$default_remote/$default_branch" | 
    #gpg --encrypt --recipient "$gpg_pub_key" >"$gpg_patch_name"
    Write-Output "Windows is not gpg support!"
} else {
    Write-Output "patch file name: $patch_name"
    git diff "$default_remote/$default_branch" | Out-File -Encoding default -FilePath $patch_name
}

[System.Console]::OutputEncoding=$TempMyOutputEncode

patch-branch

Create a patch branch

TODAY=$(date +'%Y%m%d')
git switch -c "patch-$TODAY"
$TODAY = Get-Date -UFormat '%Y%m%d'
git switch -c "patch-$today"

switch-master

Switch to DEFAULT branch

DEFAULT_BRANCH="master"
git switch "$DEFAULT_BRANCH"
$DEFAULT_BRANCH = "master"
git switch $DEFAULT_BRANCH

delete-branch

Delete patch branch

mask clean
mask switch-master
git branch --list "patch*" | xargs -n 1 git branch -D
mask clean
mask switch-master
git branch --list "patch*" | ForEach-Object{ $_ -replace " ", "" } | ForEach-Object { git branch -D $_ }

clean

Run clean

rm -f ./*.patch
rm -f ./*.patch.gpg
rm -f ./*.zip
Remove-Item *.patch
Remove-Item *.patch.gpg
Remove-Item *.zip

copy2win-patch

Copy patch to Windows

OPTIONS

  • gpg
    • flags: --gpg
    • desc: Use GPG encrypt
if [[ "$gpg" == "true" ]]; then
    cp *.patch.gpg $$WIN_HOME/Downloads/
else
    cp *.patch $WIN_HOME/Downloads/
fi
param(
    $gpg = $env:gpg
)

$TempMyOutputEncode=[System.Console]::OutputEncoding
[System.Console]::OutputEncoding=[System.Text.Encoding]::UTF8

if ($gpg) {
    Copy-Item -Path .\*.patch.gpg -Destination $env:USERPROFILE\Downloads
} else {
    Copy-Item -Path .\*.patch -Destination $env:USERPROFILE\Downloads
}

[System.Console]::OutputEncoding=$TempMyOutputEncode

test

mask lint
mask lint

lint

Run lints

mask selene-lint
mask stylua-lint
mask textlint
mask typo-check
mask shell-lint
mask selene-lint
mask stylua-lint
mask textlint
mask typo-check

stylua-lint

Run stylua lint

stylua --check ./
stylua --check ./

selene-lint

Run selene

selene .
selene .

textlint

Run textlint

pnpm run textlint
pnpm run textlint

typo-check

Run typos

typos .
typos .

shell-lint

Run shell lint (Linux only)

shellcheck --shell=bash --external-sources \
	utils/*

shfmt --language-dialect bash --diff \
	./**/*
Write-Output "Windows is not support!"

fmt

mask format
mask format

format

Run format

mask stylua-format
mask shell-format
mask stylua-format

stylua-format

Run stylua format

stylua ./
stylua ./

shell-format

Run shfmt (Linux only)

shfmt --language-dialect bash --write \
	./**/*
Write-Output "Windows is not support!"

changelog

Add commit message up to origin/master to CHANGELOG.md

TODAY=$(date "+%Y.%m.%d")
REMOTE_NAME="origin"
BRANCH_NAME="master"
RESULT_FILE="CHANGELOG.md"
GIT_LOG=$(git log "$REMOTE_NAME/$BRANCH_NAME"..HEAD --pretty=format:"%B")

{
    echo "## run"
    echo ""
    echo "$GIT_LOG" | sed -e '/^$/d' | sed -e 's/^/- /g'
    echo ""
    echo '```bash'
    echo 'git commit -m "WIP:--------------------------------------------------------------------------" --allow-empty'
    echo 'git commit -m "WIP:--------------------------------------------------------------------------" --allow-empty'
    echo "$GIT_LOG" | sed -e '/^$/d' | sed -e 's/^/git commit -m "WIP:/g' | sed -e 's/$/" --allow-empty/g'
    echo '```'
    echo ""
    echo "## [v$TODAY]"
    echo ""
    echo "### Added - 新機能について"
    echo ""
    echo "なし"
    echo ""
    echo "### Changed - 既存機能の変更について"
    echo ""
    echo "なし"
    echo ""
    echo "### Removed - 今回で削除された機能について"
    echo ""
    echo "なし"
    echo ""
    echo "### Fixed - 不具合修正について"
    echo ""
    echo "なし"
    echo ""
} >>$RESULT_FILE
Write-Output "Windows is not support now!"

pab

Create a patch branch (alias)

mask patch-branch
mask patch-branch

deleb

Delete patch branch (alias)

mask delete-branch
mask delete-branch