Skip to content

Commit

Permalink
use same formatter as ada
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 3, 2024
1 parent bb9807b commit 526839c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BasedOnStyle: Google
SortIncludes: false
SortIncludes: Never
32 changes: 15 additions & 17 deletions .github/workflows/lint_and_format_check.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
name: Lint and Format Check (Ubuntu Latest)
name: Lint and format

on:
push:
branches:
- "*"
pull_request:
push:
branches:
- "*"
- main

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ubuntu-build:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install clang-format
run: |
sudo apt update && sudo apt install clang-format-15 -y
sudo ln -sf /usr/bin/clang-format-15 /usr/bin/clang-format
- name: Build with Lint and Format Check
run: |
cmake -B build && cmake --build build
env:
CXX: clang++-14
LINT_AND_FORMAT_CHECK: true
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Run clang-format
uses: jidicula/clang-format-action@c74383674bf5f7c69f60ce562019c1c94bc1421a # v4.13.0
with:
clang-format-version: '17'
fallback-style: 'Google'
101 changes: 0 additions & 101 deletions scripts/lint_and_format.py

This file was deleted.

23 changes: 23 additions & 0 deletions scripts/run-clangcldocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
COMMAND=$*
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
MAINSOURCE=$SCRIPTPATH/..
ALL_ADA_FILES=$(cd $MAINSOURCE && git ls-tree --full-tree --name-only -r HEAD | grep -e ".*\.\(c\|h\|cc\|cpp\|hh\)\$")

if clang-format-17 --version 2>/dev/null | grep -qF 'version 17.'; then
cd $MAINSOURCE; clang-format-17 --style=file --verbose -i "$@" $ALL_ADA_FILES
exit 0
elif clang-format --version 2>/dev/null | grep -qF 'version 17.'; then
cd $MAINSOURCE; clang-format --style=file --verbose -i "$@" $ALL_ADA_FILES
exit 0
fi
echo "Trying to use docker"
command -v docker >/dev/null 2>&1 || { echo >&2 "Please install docker. E.g., go to https://www.docker.com/products/docker-desktop Type 'docker' to diagnose the problem."; exit 1; }
docker info >/dev/null 2>&1 || { echo >&2 "Docker server is not running? type 'docker info'."; exit 1; }

if [ -t 0 ]; then DOCKER_ARGS=-it; fi
docker pull kszonek/clang-format-17

docker run --rm $DOCKER_ARGS -v "$MAINSOURCE":"$MAINSOURCE":Z -w "$MAINSOURCE" -u "$(id -u $USER):$(id -g $USER)" kszonek/clang-format-17 --style=file --verbose -i "$@" $ALL_ADA_FILES

3 changes: 1 addition & 2 deletions src/to_unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ std::string to_unicode(std::string_view input) {
is_last_label ? input.size() - label_start : loc_dot - label_start;
auto label_view = std::string_view(input.data() + label_start, label_size);

if (label_view.starts_with("xn--") &&
ada::idna::is_ascii(label_view)) {
if (label_view.starts_with("xn--") && ada::idna::is_ascii(label_view)) {
label_view.remove_prefix(4);
if (ada::idna::verify_punycode(label_view)) {
std::u32string tmp_buffer;
Expand Down

0 comments on commit 526839c

Please sign in to comment.