【Git】私が書き出した40個の英語頻出コミットメッセージ

git commit 時のメッセージて素早く書きたいものですね!

すばらしい記事を見つけましたよ!

GitHubで使われている実用英語コメント集 - Qiita

実際, 入力するときには悩むメッセージも, 私でもわかりそうになる意外とシンプルな単語たちで構成されていることがわかります.

_

勉強中のPHPで書き出してみました.


<?php
$data_idiom = <<<I
Fix A in B	Bの箇所のAを修正
Fix for A	Aに対する修正
Fix A to B	BへのAを修正
Fix A of B	BのAを修正
Add A to B	BにAを追加
Add A for B	B用にAを追加
Remove A from B	BからAを除去
Remove A in B	Bの箇所のAを除去
Remove unused A	不必要なAを除去
Use A insted of B	Bの代わりにAを用いる
Use A in B	Bの箇所のAを用いる
Use A for B	BのためにAを用いる
Remove use of B	Bを用いるのを除去
Update to A	Aにアップデート
Update A to B	AをBにアップデート
Update A for B	Bに対してAをアップデート
Add A support	Aサポートを追加
Add support for A	Aに対するサポートを追加
Make use of A	Aを使用する
Make it A	よりAにする
Make sure that A	必ずAするようにする
Move A from B	BからAを移動させる
Move A to B	AをBに移動させる
Move A in B	B内のAを移動させる
Don't use A	Aを用いない
Check for A	Aに対するチェック
Check A in B	B内のAをチェック
Fix A check	Aチェックを修正
Add A check	Aチェックを追加
Remove A check	Aチェックを除去
Change A to B	AをBに変更
Change A for B	Bに対してAを変更
Change A in B	B中のAを変更
Allow A to B	AがBするのを許す
Set A to B	AをBにセット
Set A for B	Bに対してAをセット
Convert A to B	AをBに変換
Rename A to B	AをBにリネーム
Avoid A to B	BするためにAを避ける
I;

$data_adj = <<<J
new	新しい
unused	使用されていない
static	静的な
empty	空の
old	古い
small	小さな
initial	最初の
local	ローカルの
wrong	間違った
common	共通の
other	他の
dead	死んだ
get rid of	取り除く
possible	可能性のある
unneeded	不必要な
same	同じ
global	グローバルの
invalid	不正な
specific	特定の
extra	余分な
J;

$data_noun = <<<N
test	テスト
tests	テスト
code	コード
error	エラー
function	ファンクション
functions	ファンクション
driver	ドライバー
version	バージョン
typo	タイポ
docs	ドキュメント
bug	バグ
return	リターン
tag	タグ
default	デフォルト
device	デバイス
handling	ハンドリング
files	ファイル
type	タイプ
auto	オート
name	名前
data	データ
warning	警告
N;

// parse data
$idioms = array();
foreach (explode("\n", $data_idiom) as $line) {
  array_push($idioms, explode("\t", lcfirst($line)));
}

$adjs = array();
foreach (explode("\n", $data_adj) as $line) {
  array_push($adjs, explode("\t", $line));
}

$nouns = array();
foreach (explode("\n", $data_noun) as $line) {
  array_push($nouns, explode("\t", $line));
}

// build titles
foreach ($idioms as $idiom) {

  shuffle($adjs);
  shuffle($nouns);

  $title_en = str_replace(
      array('A', 'B'), 
      array($adjs[0][0] . " " . $nouns[0][0], $adjs[1][0] . " " .  $nouns[1][0]), 
      $idiom[0]);

  $title_ja = str_replace(
      array('A', 'B'), 
      array($adjs[0][1] . $nouns[0][1], $adjs[1][1] . $nouns[1][1]), 
      $idiom[1]);

  printf("%s\n%s\n\n", ucfirst($title_en), $title_ja);

}

Fix common version in new docs
新しいドキュメントの箇所の共通のバージョンを修正

Fix for dead version
死んだバージョンに対する修正

Fix new data to small code
小さなコードへの新しいデータを修正

Fix unneeded handling of local tests
ローカルのテストの不必要なハンドリングを修正

Add common device to extra functions
余分なファンクションに共通のデバイスを追加

Add unused code for specific files
特定のファイル用に使用されていないコードを追加

Remove common tests from same function
同じファンクションから共通のテストを除去

Remove unneeded default in other type
他のタイプの箇所の不必要なデフォルトを除去

Remove unused wrong bug
不必要な間違ったバグを除去

Use static docs instead of wrong tests
間違ったテストの代わりに静的なドキュメントを用いる

Use small return in unneeded code
不必要なコードの箇所の小さなリターンを用いる

Use old error for extra test
余分なテストのために古いエラーを用いる

Remove use of new files
新しいファイルを用いるのを除去

Update to small code
小さなコードにアップデート

Update empty code to unneeded test
空のコードを不必要なテストにアップデート

Update empty test for static device
静的なデバイスに対して空のテストをアップデート

Add static bug support
静的なバグサポートを追加

Add support for small default
小さなデフォルトに対するサポートを追加

Make use of other warning
他の警告を使用する

Make it extra auto
より余分なオートにする

Make sure that small typo
必ず小さなタイポするようにする

Move get rid of device from new version
新しいバージョンから取り除くデバイスを移動させる

Move old data to static files
古いデータを静的なファイルに移動させる

Move small return in other tag
他のタグ内の小さなリターンを移動させる

Don't use local function
ローカルのファンクションを用いない

Check for specific data
特定のデータに対するチェック

Check other default in initial version
最初のバージョン内の他のデフォルトをチェック

Fix common tag check
共通のタグチェックを修正

Add specific auto check
特定のオートチェックを追加

Remove same data check
同じデータチェックを除去

Change unused test to global error
使用されていないテストをグローバルのエラーに変更

Change extra type for invalid driver
不正なドライバーに対して余分なタイプを変更

Change other data in get rid of return
取り除くリターン中の他のデータを変更

Allow unneeded device to dead default
不必要なデバイスが死んだデフォルトするのを許す

Set empty bug to dead auto
空のバグを死んだオートにセット

Set unneeded functions for empty device
空のデバイスに対して不必要なファンクションをセット

Convert specific driver to invalid functions
特定のドライバーを不正なファンクションに変換

Rename specific files to local test
特定のファイルをローカルのテストにリネーム

Avoid small typo to initial name
最初の名前するために小さなタイポを避ける

微妙な結果ですね!

まとめ

「イディオム」てやつを覚えるといいのかもしれませんね!!

Gitのコミットメッセージの書き方 | プログラミング | POSTD


Espresso で アイドリング

espresso

Espresso は以下の非同期処理は考慮してくれるようですが.

- メッセージキューを利用したUIイベント
- デフォルト AsyncTask のスレッドプールを利用したタスク

Square Island: Espresso: Custom Idling Resource

これらに該当しない処理でも, テスト実行を「あるタイミング」まで待たせたいときがありますよね?

カスタムした「IdlingResource」を使ってみましょう.

Espresso Idling Resource

ここで書かれているアプローチとしては2つ.

Counting running jobs: When a job starts, increment a counter. When it finishes, decrement it. The app is idle if the counter is zero. This approach is very simple and accounts for most situations. CountingIdlingResource does exactly this.

Querying state: It might be more reliable to ask a work queue or an HTTP client (or whatever is doing the background work) if it is busy. If the state is exposed, implementing an Idling Resource is trivial.

これらのうち, 汎用的に使えるジョブカウンターを利用した方法を, Googleサンプルを眺めつつ手順整理しておきます.

Android Testing Codelab

1. IdlingResource ユーティリティの作成

アイドリング向けのユーテリティを作成します.
そのまま2つのクラスを利用してもいいかもしれません.

EspressoIdlingResource.java at master · googlecodelabs/android-testing

SimpleCountingIdlingResource.java at master · googlecodelabs/android-testing

2. テスト対象の Activity に記述

テスト対象となる Activity にテスト時に利用するメソッドを記述しておきます.
テスト時にはこのメソッドを利用して, 先ほどのユーティリティを利用登録します.


    @VisibleForTesting
    public IdlingResource getCountingIdlingResource() {
        return EspressoIdlingResource.getIdlingResource();
    }

AddNoteActivity.java at master · googlecodelabs/android-testing

NotesActivity.java at master · googlecodelabs/android-testing

3. 「待たせる」処理の記述

Presenter や View などのテスト対象クラス内にアイドリングの利用タイミングを記述しておきます.


EspressoIdlingResource.increment(); 


EspressoIdlingResource.decrement(); 

カウンターを増減しながらアイドリングを操作します.
カウンターが0になると処理が再開されます.


    @Override
    public void loadNotes(boolean forceUpdate) {
        mNotesView.setProgressIndicator(true);
        if (forceUpdate) {
            mNotesRepository.refreshData();
        }

        // The network request might be handled in a different thread so make sure Espresso knows
        // that the app is busy until the response is handled.
        EspressoIdlingResource.increment(); // App is busy until further notice

        mNotesRepository.getNotes(new NotesRepository.LoadNotesCallback() {
            @Override
            public void onNotesLoaded(List<Note> notes) {
                EspressoIdlingResource.decrement(); // Set app as idle.
                mNotesView.setProgressIndicator(false);
                mNotesView.showNotes(notes);
            }
        });
    }

AddNoteFragment.java at master · googlecodelabs/android-testing

NotesPresenter.java at master · googlecodelabs/android-testing

4. テスト内で登録する

テスト対象Activityに記述したメソッドを利用してテストコードへ登録します
アイドリング処理がテスト時に反映されます.


    @Before
    public void registerIdlingResource() {
        Espresso.registerIdlingResources(
                mAddNoteIntentsTestRule.getActivity().getCountingIdlingResource());
    }

    @After
    public void unregisterIdlingResource() {
        Espresso.unregisterIdlingResources(
                mAddNoteIntentsTestRule.getActivity().getCountingIdlingResource());
    }

AddNoteScreenTest.java at master · googlecodelabs/android-testing

まとめ

テストにかかるコストがただの自己満足で終わらないようにしたいです.

JakeWharton/okhttp-idling-resource: An Espresso IdlingResource for OkHttp.

PSA: Dont Use Espresso Idling Resources like Google does · Philosophical Hacker


LINE Notify をつかってターミナルから送信する

使ってみる.

line-notify

コマンドラインから LINE にメッセージを送れる LINE Notify « LINE Engineers' Blog

とりあえず.


#!/bin/sh -x                                                                                                                                   

token=zbOIf0lthC34fLGsXuilN2WBIkbomhtKj18M1MP0B1g

while true
do
  read message
  curl https://notify-api.line.me/api/notify \
  -H "Authorization: Bearer ${token}" \
  -F "message=${message} https://goo.gl/lU0Kx6" \
  -F "imageThumbnail=https://pbs.twimg.com/profile_images/745806811597406210/HO0KCGf2_400x400.jpg" \
  -F "imageFullsize=http://developers.linecorp.com/blog/wp-content/uploads/2016/10/moon.png"
  echo
done

これはグループ向けのメッセージ通知用になるのかな.