Skip to content

yasuke-kuroda-diezon/script__git

Repository files navigation

概要

複数のリポジトリが存在する環境で、 複数のリポジトリに対して一括でgit操作を行えるスクリプト群です。

誤った指定に対しては、警告を表示しmerge/push実行しないことで、事故を防止しています。

使い方

初回のみ

  1. eccube/ 配下に、本コードを配置します. (初回のみ)
cd eccube_web/eccube/
git clone git@github.com:yasuke-kuroda-diezon/script__git.git
  1. 本コードを、ec-cubeリポジトリのGit管理の対象外とします. (初回のみ)
echo "script__git/" >> .git/info/exclude
  1. スクリプトに実行権限を付与します (初回のみ)
chmod +x ./script__git/*.sh

日々の使い方

  1. configファイルに、ブランチの設定を記述します.

(※設定の記述方法は、ファイル内に記載しています)

vim script__git/config/config.sh
  1. スクリプト実行します (例)
./script__git/pull.sh
./script__git/delete_fully_merged_branch.sh

スクリプト一覧

以下のファイルは編集不要です。 対象ブランチは、script__git/config/config.shの内容を読み込んで実行します。

コマンド 1つずつのリポジトリに対して行う処理
./script__git/pull.sh git pullを実行
./script__git/checkout.sh git checkoutを実行
./script__git/restore.sh git restoreを実行
./script__git/merge_and_push.sh git merge && git pushを実行
./script__git/delete_untracked_files.sh git clean -fを実行(git管理してないファイルを削除します)
./script__git/delete_fully_merged_branch.sh git branch -dを実行(マージ済みブランチを安全に削除します。feature作業ブランチなど。)

ディレクトリ構成

script__git/
├── config/
│   └── config.sh      # 設定ファイル.
├── base/
│   └── main.sh
├── lib/
│   ├── git_command.sh # gitコマンド一覧.
│   ├── log.sh
│   └── task.sh        # gitコマンドを組み合わせたタスクセットの一覧.
├── checkout.sh
├── delete_fully_merged_branch.sh
├── delete_untracked_files.sh
├── merge_and_push.sh
├── pull.sh
├── restore.sh
└── README.md

安全への配慮

./script__git/merge_and_push.shを実行する際、以下のような危険な操作を防ぐためのバリデーションを行っています。

  1. main(master)ブランチ上で、git merge xxxを実行することはできません (=main(master)ブランチは、別ブランチにマージされることのみ許可します)
スクリーンショット 2025-10-05 15 46 11
  1. yyyブランチ上で、git merge stagingを実行することはできません (=staging(develop)ブランチは、別ブランチをマージすることのみ許可します)
スクリーンショット 2025-10-05 16 02 42

Regolith Headless対応

config/config.shprojectType="RegolithHeadless"を指定することで対応可能です。

cd regolith-docker/
echo "script__git/" >> .git/info/exclude
chmod +x ./script__git/*.sh
./script__git/pull.sh

メモ

ディレクトリ構成に悩みました。

  • スクリプトはbin/に入れたかったけど、実行パスがその分長くなってしまい使いやすさを失うので、bin/に入れず、本リポジトリの直下にスクリプト群を配置しました.
  • main.shは実行権限を付与する必要がなく、mを入力してタブキー押下でmerge_and_push.shを実行できるように、実行スクリプト群とmain.shのディレクトリを分けました。
  • core/main.shにすると、config/coまで重複するので、coまで入力してタブキー押下で設定ファイルが開けなくなるので、core/は採用できず、base/にしました。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages