forked from eclipse-embed-cdt/eclipse-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_fix_file_permissions.sh
executable file
·31 lines (28 loc) · 1.19 KB
/
do_fix_file_permissions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
###############################################################################
# Copyright (c) 2018, 2020 Kichwa Coders Ltd and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
set -e
##
# Remove execute permission from all files in the repository.
##
echo "Removing execute permission from all files in repository"
git ls-files -z | xargs --null --no-run-if-empty chmod -x
##
# Enforce certain file types to have execute permission.
# The .gitattributes is used as a filter to identify files to add execute
# permissions to. Patterns with this "# file permission +x" on the line before
# are considered (lines in .gitattributes starting with '#' are ignored).
##
awk '/# file permission \+x/{do getline; while ($0 ~ /^#/); print $1}' .gitattributes |
while read i ; do
echo "Adding execute permission to $i files"
git ls-files -z -- "$i" | xargs --null --no-run-if-empty chmod +x
done