From 63879be317e55c0b2a45af1a8b4f2adf26f29494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Tue, 5 Dec 2023 16:36:19 +0100 Subject: [PATCH] Upload New File --- .ci_templates/.clang_format.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .ci_templates/.clang_format.yml diff --git a/.ci_templates/.clang_format.yml b/.ci_templates/.clang_format.yml new file mode 100644 index 000000000..dc263197d --- /dev/null +++ b/.ci_templates/.clang_format.yml @@ -0,0 +1,29 @@ +.clang_format_script: + + - apt install -y clang-format-12 # available in ubuntu 20.04 or newer + - cd $CI_PROJECT_DIR + + # configure git + - git remote set-url origin "ssh://git@gitlab.iri.upc.edu:2202/${CI_PROJECT_PATH}.git" + - git pull origin ${CI_COMMIT_REF_NAME} + - git config --global user.email "${CI_EMAIL}" + - git config --global user.name "${CI_USERNAME}" + + # create temporary branch + - if [ `git rev-parse --verify ci_clangformat 2>/dev/null` ]; then + - git branch --delete ci_clangformat + - fi + - export CI_NEW_BRANCH_CLANG=ci_clangformat + - echo creating new temporary branch... $CI_NEW_BRANCH_CLANG + - git checkout -b $CI_NEW_BRANCH_CLANG + + # apply clang format to all code files + - cd ${CI_PROJECT_DIR} + - find . -iname *.h -o -iname *.cpp -o -iname *.hpp | xargs clang-format-12 --style=file -i + + # push changes (if any) + - if git commit -a -m "[skip ci] applied clang format" ; then + - git push origin $CI_NEW_BRANCH_CLANG:${CI_COMMIT_REF_NAME} + - else + - echo "No changes, nothing to commit!" + - fi \ No newline at end of file -- GitLab