Skip to content

Commit acfa289

Browse files
authored
Fix DIRECTORY.md formatting (closes TheAlgorithms#3922) (TheAlgorithms#4124)
1 parent 3b2ca81 commit acfa289

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/update_directory.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push
1+
# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push or pull_request
22
name: Update Directory
3+
permissions:
4+
contents: write
35
on:
46
push:
57
paths:
68
- 'src/**'
7-
- '**.yml'
8-
- '**.xml'
9-
- '**.Dockerfile'
109
pull_request:
1110
paths:
1211
- 'src/**'
13-
- '**.yml'
14-
- '**.xml'
15-
- '**.Dockerfile'
12+
workflow_dispatch:
13+
inputs:
14+
logLevel:
15+
description: 'Log level'
16+
required: true
17+
default: 'info'
18+
type: choice
19+
options:
20+
- info
21+
- warning
22+
- debug
1623
jobs:
1724
update_directory_md:
1825
runs-on: ubuntu-latest
@@ -46,8 +53,12 @@ jobs:
4653
def print_path(old_path: str, new_path: str) -> str:
4754
global g_output
4855
old_parts = old_path.split(os.sep)
49-
for i, new_part in enumerate(new_path.split(os.sep)):
50-
if i + 1 > len(old_parts) or old_parts[i] != new_part:
56+
mid_diff = False
57+
new_parts = new_path.split(os.sep)
58+
for i, new_part in enumerate(new_parts):
59+
if i + 1 > len(old_parts) or old_parts[i] != new_part or mid_diff:
60+
if i + 1 < len(new_parts):
61+
mid_diff = True
5162
if new_part:
5263
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ')}")
5364
return new_path
@@ -56,7 +67,7 @@ jobs:
5667
def build_directory_md(top_dir: str = ".") -> str:
5768
global g_output
5869
old_path = ""
59-
for filepath in sorted(good_filepaths(), key=str.lower):
70+
for filepath in sorted(good_filepaths(top_dir), key=str.lower):
6071
filepath, filename = os.path.split(filepath)
6172
if filepath != old_path:
6273
old_path = print_path(old_path, filepath)

0 commit comments

Comments
 (0)