Repository: mesos Updated Branches: refs/heads/master d9ffd6bef -> ded16b00c
MESOS-1712: Automated disallowing of commits mixing mesos/libprocess/stout. Review: https://reviews.apache.org/r/26825 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ded16b00 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ded16b00 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ded16b00 Branch: refs/heads/master Commit: ded16b00c9dcb48341d40a167de6ea475c85de06 Parents: d9ffd6b Author: Cody Maloney <[email protected]> Authored: Fri Oct 24 11:14:38 2014 -0700 Committer: Vinod Kone <[email protected]> Committed: Fri Oct 24 11:14:39 2014 -0700 ---------------------------------------------------------------------- support/hooks/pre-commit | 3 ++ support/mesos_split.py | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/ded16b00/support/hooks/pre-commit ---------------------------------------------------------------------- diff --git a/support/hooks/pre-commit b/support/hooks/pre-commit index f6910f8..09ce578 100755 --- a/support/hooks/pre-commit +++ b/support/hooks/pre-commit @@ -25,3 +25,6 @@ git diff-index --check --cached $against -- || exit 1 # Check Mesos style. exec git diff --cached --name-only --diff-filter=AM | xargs ./support/mesos-style.py + +# Check that the commits are properly split between mesos, libprocess and stout. +exec git diff --cached --name-only --diff-filter=AMD | xargs ./support/mesos_split.py http://git-wip-us.apache.org/repos/asf/mesos/blob/ded16b00/support/mesos_split.py ---------------------------------------------------------------------- diff --git a/support/mesos_split.py b/support/mesos_split.py new file mode 100755 index 0000000..be30bd5 --- /dev/null +++ b/support/mesos_split.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Errors if a list of files spans across the projects which make up +# mesos. + +if __name__ != "__main__": + raise Exception("This is not a libraray") + +from collections import defaultdict +import sys + +if len(sys.argv) < 2: + print "Usage: ./mesos-split.py <filename>..." + +base_project = "mesos" +subprojects = { + "libprocess": "3rdparty/libprocess", + "stout": "3rdparty/libprocess/3rdparty/stout" +} +ERROR = """ERROR: Commit spanning multiple projects. + +Please use separate commits for mesos, libprocess and stout. + +Paths grouped by project:""" + + +def find_project(filename): + # Find longest prefix match. + found_path_len = 0 + found_project = base_project + for project, path in subprojects.iteritems(): + if filename.startswith(path) and len(path) > found_path_len: + found_path_len = len(path) + found_project = project + + return found_project + + +touched_projects = defaultdict(list) +for filename in sys.argv[1:]: + touched_projects[find_project(filename)].append(filename) + +if len(touched_projects) > 1: + print ERROR + for project in touched_projects.iterkeys(): + print "%s:" % project + for filename in touched_projects[project]: + print " %s" % filename + sys.exit(1) + +sys.exit(0)
