Skip to content

Commit

Permalink
Add separate script for setting up formatting for a repository. (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl authored Nov 7, 2023
1 parent 0ec3973 commit 8bc082c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
2 changes: 2 additions & 0 deletions scripts/_Team_Defines.bash
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ alias setup-repository=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-repository.bash

alias setup-repository-ci=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-repository-ci.bash

alias setup-formatting=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-formatting.bash

alias setup-ros-workspace=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-ros-workspace.bash

setup-ros-workspace () {
Expand Down
35 changes: 35 additions & 0 deletions scripts/setup-formatting.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright 2023 Stogl Robotics Consulting UG (haftungsbeschränkt)
#
# Licensed 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.
#
#
# Author: Dr. Denis Stogl


usage='setup-formatting.bash'

# Load Framework defines
script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
source $script_own_dir/../setup.bash

# Setting up formatting
cp -n ${PACKAGE_TEMPLATES}/.clang-format .
cp -n ${PACKAGE_TEMPLATES}/.pre-commit-config.yaml .
touch ".codespell-ignore-words.txt"
pre-commit install
pre-commit autoupdate

echo ""
echo -e "${TERMINAL_COLOR_BLUE}FINISHED formatting setup: Now commit the formatting configuration and format all files using \`pre-commit run -a\` command.${TERMINAL_COLOR_NC}"
6 changes: 1 addition & 5 deletions scripts/setup-repository-ci.bash
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ read -p "${RAW_TERMINAL_COLOR_BROWN}Do you want to setup formatting using pre-co
formatting=${formatting:="no"}

if [[ "$formatting" == "yes" ]]; then
cp -n ${PACKAGE_TEMPLATES}/.clang-format .
cp -n ${PACKAGE_TEMPLATES}/.pre-commit-config.yaml .
touch ".codespell-ignore-words.txt"
pre-commit install
pre-commit autoupdate
$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-formatting.bash
fi

echo ""
Expand Down
11 changes: 7 additions & 4 deletions scripts/setup-repository.bash
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ case "$choice" in
exit 0
esac

cp -n $PACKAGE_TEMPLATES/.clang-format .
cp -n $PACKAGE_TEMPLATES/.pre-commit-config.yaml .
pre-commit install
pre-commit autoupdate
# Setting up formatting
read -p "${RAW_TERMINAL_COLOR_BROWN}Do you want to setup formatting using pre-commit?${RAW_TERMINAL_COLOR_NC} (yes/no) [no]: " formatting
formatting=${formatting:="no"}

if [[ "$formatting" == "yes" ]]; then
$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-formatting.bash
fi


# This functionality is not provided in all framework versions
Expand Down

0 comments on commit 8bc082c

Please sign in to comment.