大量のコードをレビューする際(特に自動生成ファイルや画像ファイルが含まれている場合)には、一旦全てのDiffを折りたたんでからレビューを進めたいと思う事があります。
普通にあっても良さそうな機能ですが、現時点では実装されてません。
Feature Proposalとして、既に以下のページに上がっているのでそのうち実装されるとは思いますが・・。
[Workaround]
この機能が実装されるまでは、以下のページに記載されていた方法で[Collapse All]ボタンをDiffのページに追加する事ができます。
- Chrome を起動。
- [F12] をクリック。
- "Sources" をクリック。
- "Snippets" タブをクリック。
- "+ New snippet"をクリック。
- Snippetの名前を付けた後、以下のコードを貼り付け、保存する。
- 作成したSnippetを選択し、右クリックした後"Run"を選択する。
/*
* GiblabのDiffページに[Collapse All] ボタンを追加するsnippet
*/
// Collapse All ボタンの作成
function createCollapseAllButton() {
var button = document.createElement('button');
button.setAttribute('id', 'collapse-all');
button.setAttribute('class', 'btn btn-default');
button.setAttribute('type', 'button');
button.textContent = 'Collapse All';
return button;
}
// Collapse All ボタンをクリックした際のイベントハンドラ
function collapseAll(event) {
$('.diff-file').find('div.nothing-here-block').each(function(i) {
if (!$(this).is(':visible')) {
$(this).parents('div.file-holder').find('div.file-title-flex-parent').trigger('click');
}
});
}
var buttons = document.getElementsByClassName('inline-parallel-buttons')[0];
buttons.insertBefore(createCollapseAllButton(), buttons.firstChild);
// Collapse All ボタンを有効化
document.getElementById('collapse-all').addEventListener('click', collapseAll, false);
[参考URL]
Button to collapse all diffs (#24679) · Issues · GitLab.org / GitLab Community Edition · GitLab