From 599a9dc518573701729b427bbe2a5f74309470d0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 01 2015 11:46:00 +0000 Subject: Add a method to detect if a changed set was force pushed or not --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 9029f31..318e8ca 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -806,6 +806,15 @@ def get_revs_between(torev, fromrev, abspath): return pagure.lib.git.read_git_lines(cmd, abspath) +def is_forced_push(torev, fromrev, abspath): + """ Returns wether there was a force push between HEAD and BASE. """ + + # Returns if there was any commits deleted in the changeset + cmd = ['rev-list', '%s' % torev, '^%s' % (fromrev)] + out = pagure.lib.git.read_git_lines(cmd, abspath) + return len(out) > 0 + + def get_pusher(commit, abspath): ''' Return the name of the person that pushed the commit. ''' user = pagure.lib.git.read_git_lines(