Skip to content

Latest commit

 

History

History
459 lines (349 loc) · 7.48 KB

maskfile.md

File metadata and controls

459 lines (349 loc) · 7.48 KB

Tasks for generate-readme.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="generate-readme.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 = "windows_generate-readme.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
mask shell-lint

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")
RESULT_FILE="CHANGELOG.md"
LATEST_GIT_TAG=$(git tag | head -n 1)
GIT_LOG=$(git log "$LATEST_GIT_TAG..HEAD" --pretty=format:"%B")
HOSTNAME=$(hostname)

home() {
    echo "## [v$TODAY]"
    echo ""
    echo "$GIT_LOG" |
        # Remove blank line
        sed -e '/^$/d' |
        # Make list
        sed -e 's/^/- /g'
    echo ""
    echo "### Added - 新機能について"
    echo ""
    echo "なし"
    echo ""
    echo "### Changed - 既存機能の変更について"
    echo ""
    echo "なし"
    echo ""
    echo "### Removed - 今回で削除された機能について"
    echo ""
    echo "なし"
    echo ""
    echo "### Fixed - 不具合修正について"
    echo ""
    echo "なし"
    echo ""
}

work() {
    echo "## run"
    echo ""
    echo '```bash'
    echo 'git commit -m "WIP:--------------------------------------------------------------------------" --allow-empty --no-verify'
    echo "$GIT_LOG" |
        # Remove blank line
        sed -e '/^$/d' |
        # Remove STARTUPTIME.md commit msg
        sed -e 's/.*STARTUPTIME.md.*//g' |
        # Remove DROP commit msg
        sed -e 's/.*DROP.*//g' |
        # Remove blank line
        sed -e '/^$/d' |
        sed -e 's/^/git commit -m "WIP:/g' |
        sed -e 's/$/" --allow-empty --no-verify/g'
    echo 'git commit -m "WIP:--------------------------------------------------------------------------" --allow-empty --no-verify'
    echo '```'
}

if [[ "$HOSTNAME" = "TanakaPC" ]]; then
    work >>$RESULT_FILE
else
    home >>$RESULT_FILE
fi
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