Skip to content

Commit 7c54c61

Browse files
authored
Merge pull request #99 from doubleopen-project/sorting
Sorting
2 parents a0f46a1 + 7e25e0f commit 7c54c61

File tree

3 files changed

+31
-69
lines changed

3 files changed

+31
-69
lines changed

.github/workflows/check.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ jobs:
3737
- name: Lint YAML files
3838
run: yamllint license-classifications.yml
3939

40+
Sort:
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Clone the repository
45+
uses: actions/checkout@v4
46+
- name: Sort YAML files
47+
run: |
48+
./sort-licenses.sh
49+
git diff --quiet
50+
4051
REUSE:
4152
runs-on: ubuntu-latest
4253

sort-licenses.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

sort-licenses.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/env bash
2+
3+
# SPDX-FileCopyrightText: 2025 Double Open Oy <[email protected]>
4+
# SPDX-License-Identifier: CC0-1.0
5+
6+
# Avoid multi-line strings being unwrapped by `yq`.
7+
# This works around https://github.com/mikefarah/yq/issues/439.
8+
sed -i 's,>-,|,g' license-classifications.yml
9+
10+
# Replace empty lines with marker comments.
11+
# This works around https://github.com/mikefarah/yq/issues/515.
12+
sed -i 's,^$,#EMPTY_LINE,g' license-classifications.yml
13+
14+
yq -i '.categorizations |= sort_by(.id)' license-classifications.yml
15+
16+
# Replace marker comments (with potential indentation added by `yq`) with empty lines.
17+
sed -i 's, *#EMPTY_LINE,,g' license-classifications.yml
18+
19+
# Restore original folded blocks with stripped newlines.
20+
sed -i 's,|,>-,g' license-classifications.yml

0 commit comments

Comments
 (0)