diff --git a/pagure/lib/git.py b/pagure/lib/git.py index bfc4485..d9b9d12 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1046,6 +1046,9 @@ def is_forced_push(oldrev, newrev, abspath): Doc: http://stackoverflow.com/a/12258773 """ + if set(oldrev) == set('0'): + # This is a push that's creating a new branch => certainly ok + return False # Returns if there was any commits deleted in the changeset cmd = ['rev-list', '%s' % oldrev, '^%s' % newrev] out = pagure.lib.git.read_git_lines(cmd, abspath) diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 0e22eea..1892b8a 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -3194,6 +3194,15 @@ index 0000000..60f7480 cwd='/tmp', shell=True, stderr=-1, stdout=-1 ) + def test_is_forced_push_new_branch(self): + self.assertFalse( + pagure.lib.git.is_forced_push( + '0000000000000000000000000000000000000000', + '^0e6e0b6c931d65ee22f67205a53933d841c6eeff', + 'path/is/not/important' + ) + ) + if __name__ == '__main__': unittest.main(verbosity=2)