From 7968b1c836f6410514bad6fddc231d5030c05986 Mon Sep 17 00:00:00 2001 From: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Wed, 24 May 2017 10:49:11 +0200 Subject: [PATCH] dim: Enforce review requirements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can't check this when applying (since r-b/a-b tags often get added afterwards), but we can check this when pushing. This only looks at patches authored by the pusher. Also update the docs to highlight that review requirements hold especially also for bugfixes. v2: committer instead of committer (Sean/Chris). Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Cc: Lukas Wunner <lukas@wunner.de> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Christian König <deathsimple@vodafone.de> Cc: Sean Paul <seanpaul@chromium.org> Acked-by: Sean Paul <seanpaul@chromium.org> Acked-by: Jani Nikula <jani.nikula@linux.intel.com> Reviewed-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> --- dim | 46 ++++++++++++++++++++++++++++++++++++++++------ drm-misc.rst | 4 +++- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dim b/dim index baa0b38..5e63c53 100755 --- a/dim +++ b/dim @@ -340,6 +340,15 @@ function git_branch_exists # branch fi } +function git_committer_email +{ + if ! committer_email=$(git config --get user.email) ; then + committer_email=$EMAIL + fi + + echo $committer_email +} + # get message id from file # $1 = file message_get_id () @@ -632,11 +641,32 @@ function dim_rebuild_tip exit 1 fi } + +# additional patch checks before pushing, e.g. for r-b tags +function checkpatch_commit_push +{ + local sha1 + + sha1=$1 + + # check for a-b/r-b tag + if git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:' ; then + return + fi + + # check for committer != author + if [[ $(git show -s $sha1 --format="format:%ce") != $(git show -s $sha1 --format="format:%ae") ]]; then + return + fi + + warn_or_fail "$sha1 is lacking mandatory review" +} + # push branch $1, rebuild drm-tip. the rest of the arguments are passed to git # push. function dim_push_branch { - local branch remote + local branch remote committer_email branch=${1:?$usage} shift @@ -645,6 +675,12 @@ function dim_push_branch remote=$(branch_to_remote $branch) + committer_email=$(git_committer_email) + + for sha1 in $(git rev-list $branch@{u}..$branch --committer="$committer_email" --no-merges) ; do + checkpatch_commit_push $sha1 + done + git push $DRY_RUN $remote $branch "$@" update_linux_next $branch drm-intel-next-queued drm-intel-next-fixes drm-intel-fixes @@ -677,7 +713,7 @@ dim_alias_ab=apply-branch dim_alias_sob=apply-branch function dim_apply_branch { - local branch file message_id commiter_email patch_from sob rv + local branch file message_id committer_email patch_from sob rv branch=${1:?$usage} shift @@ -690,12 +726,10 @@ function dim_apply_branch message_id=$(message_get_id $file) - if ! commiter_email=$(git config --get user.email) ; then - commiter_email=$EMAIL - fi + committer_email=$(git_committer_email) patch_from=$(grep "From:" "$file" | head -1) - if [[ "$patch_from" != *"$commiter_email"* ]] ; then + if [[ "$patch_from" != *"$committer_email"* ]] ; then sob=-s fi diff --git a/drm-misc.rst b/drm-misc.rst index caba8dc..d56c3c7 100644 --- a/drm-misc.rst +++ b/drm-misc.rst @@ -90,7 +90,9 @@ Merge Criteria Right now the only hard merge criteria are: * Patch is properly reviewed or at least Ack, i.e. don't just push your own - stuff directly. + stuff directly. This rule holds even more for bugfix patches - it would be + embarrassing if the bugfix contains a small gotcha that review would have + caught. * drm-misc is for drm core (non-driver) patches, subsystem-wide refactorings, and small trivial patches all over (including drivers). For a detailed list of -- GitLab