1# Copyright 2014, VIXL authors 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are met: 6# 7# * Redistributions of source code must retain the above copyright notice, 8# this list of conditions and the following disclaimer. 9# * Redistributions in binary form must reproduce the above copyright notice, 10# this list of conditions and the following disclaimer in the documentation 11# and/or other materials provided with the distribution. 12# * Neither the name of ARM Limited nor the names of its contributors may be 13# used to endorse or promote products derived from this software without 14# specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND ANY 17# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19# DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, 20# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 22# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 25# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 27import re 28import util 29import os.path 30 31def is_git_repository_root(path): 32 return os.path.isdir(os.path.join(path, '.git')) 33 34def get_tracked_files(): 35 command = 'git ls-tree HEAD -r --full-tree --name-only' 36 37 status, tracked = util.getstatusoutput(command) 38 if status != 0: util.abort('Failed to list tracked files.') 39 40 return tracked 41 42 43# Get untracked files in src/, test/, and tools/. 44def get_untracked_files(): 45 status, output = util.getstatusoutput('git status -s') 46 if status != 0: util.abort('Failed to get git status.') 47 48 untracked_regexp = re.compile('\?\?.*(src/|test/|tools/).*(.cc$|.h$)') 49 files_in_watched_folder = lambda n: untracked_regexp.search(n) != None 50 untracked_files = filter(files_in_watched_folder, output.split('\n')) 51 52 return untracked_files 53