]> Nutra Git (v2) - gamesguru/git-remote-gcrypt.git/commitdiff
lint/format
authorShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 21:31:32 +0000 (16:31 -0500)
committerShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 21:31:32 +0000 (16:31 -0500)
Makefile
tests/sync_docs.py

index 097863f2b3b37da30b567e6a980badf5fa138754..fe19f9de4c2e8fb335af14bb09dc41a9bef20f4a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ lint: ##H Run shellcheck
        shellcheck install.sh
        @$(call print_success,OK.)
        # lint system/binary script
-       shellcheck git-remote-gcrypt
+       shellcheck -e SC3043,SC2001 git-remote-gcrypt
        @$(call print_success,OK.)
        # lint test scripts
        shellcheck tests/*.sh
index c3a69698ad620c5c3b09cfa5bc62a260fb61fb0e..803403ee30cbdbe3efe9d3b9e437c44b3899fab7 100755 (executable)
 #!/usr/bin/env python3
-import re
 import os
+import re
 import sys
 
+
 def extract_help_text(script_path):
-    with open(script_path, 'r') as f:
+    with open(script_path, "r") as f:
         content = f.read()
-    
+
     match = re.search(r'HELP_TEXT="(.*?)"', content, re.DOTALL)
     if not match:
         print("Error: Could not find HELP_TEXT in git-remote-gcrypt", file=sys.stderr)
         sys.exit(1)
     return match.group(1)
 
+
 def parse_commands(help_text):
     commands = []
     # Look for lines starting with lowercase words in the Options: or Git Protocol Commands sections
-    lines = help_text.split('\n')
+    lines = help_text.split("\n")
     capture = False
     for line in lines:
         line = line.strip()
-        if line.startswith('Options:') or line.startswith('Git Protocol Commands'):
+        if line.startswith("Options:") or line.startswith("Git Protocol Commands"):
             capture = True
             continue
-        if line.startswith('Environment Variables:'):
+        if line.startswith("Environment Variables:"):
             capture = False
             continue
-        
+
         if capture and line:
             # Match lines like "check [URL]      Description" or "capabilities     Description"
-            match = re.match(r'^([a-z-]+)(\s+.*)?$', line)
+            match = re.match(r"^([a-z-]+)(\s+.*)?$", line)
             if match:
                 cmd = match.group(1)
-                if cmd not in ['help', 'version']:
+                if cmd not in ["help", "version"]:
                     commands.append(cmd)
     return sorted(list(set(commands)))
+
+
 def update_bash_completion(path, commands):
-    if not os.path.exists(path): return
-    with open(path, 'r') as f: content = f.read()
-    cmd_str = ' '.join(commands)
+    if not os.path.exists(path):
+        return
+    with open(path, "r") as f:
+        content = f.read()
+    cmd_str = " ".join(commands)
     new_content = re.sub(r'commands="[^"]+"', f'commands="{cmd_str}"', content)
-    with open(path, 'w') as f: f.write(new_content)
+    with open(path, "w") as f:
+        f.write(new_content)
+
 
 def update_zsh_completion(path, commands):
-    if not os.path.exists(path): return
-    with open(path, 'r') as f: content = f.read()
-    cmd_str = ' '.join(commands)
+    if not os.path.exists(path):
+        return
+    with open(path, "r") as f:
+        content = f.read()
+    cmd_str = " ".join(commands)
     # Match 1:command:(capabilities list push fetch check clean)
-    new_content = re.sub(r'1:command:\([^)]+\)', f'1:command:({cmd_str})', content)
-    with open(path, 'w') as f: f.write(new_content)
+    new_content = re.sub(r"1:command:\([^)]+\)", f"1:command:({cmd_str})", content)
+    with open(path, "w") as f:
+        f.write(new_content)
+
 
 def update_fish_completion(path, commands):
-    if not os.path.exists(path): return
-    with open(path, 'r') as f: content = f.read()
+    if not os.path.exists(path):
+        return
+    with open(path, "r") as f:
+        content = f.read()
     # Replace the list in "not __fish_seen_subcommand_from ..."
-    cmd_str = ' '.join(commands)
-    new_content = re.sub(r'not __fish_seen_subcommand_from [^"]+', f'not __fish_seen_subcommand_from {cmd_str}', content)
-    with open(path, 'w') as f: f.write(new_content)
+    cmd_str = " ".join(commands)
+    new_content = re.sub(
+        r'not __fish_seen_subcommand_from [^"]+',
+        f"not __fish_seen_subcommand_from {cmd_str}",
+        content,
+    )
+    with open(path, "w") as f:
+        f.write(new_content)
+
 
 def main():
     script_dir = os.path.dirname(os.path.abspath(__file__))
     root_dir = os.path.dirname(script_dir)
-    script_path = os.path.join(root_dir, 'git-remote-gcrypt')
-    
+    script_path = os.path.join(root_dir, "git-remote-gcrypt")
+
     help_text = extract_help_text(script_path)
     commands = parse_commands(help_text)
-    
+
     # We always want protocol commands in completions too
-    comp_commands = sorted(list(set(commands + ['capabilities', 'list', 'push', 'fetch'])))
-    
+    comp_commands = sorted(
+        list(set(commands + ["capabilities", "list", "push", "fetch"]))
+    )
+
     print(f"Detected commands: {' '.join(comp_commands)}")
-    
-    update_bash_completion(os.path.join(root_dir, 'completions/bash/git-remote-gcrypt'), comp_commands)
-    update_zsh_completion(os.path.join(root_dir, 'completions/zsh/_git-remote-gcrypt'), comp_commands)
-    update_fish_completion(os.path.join(root_dir, 'completions/fish/git-remote-gcrypt.fish'), comp_commands)
-    
+
+    update_bash_completion(
+        os.path.join(root_dir, "completions/bash/git-remote-gcrypt"), comp_commands
+    )
+    update_zsh_completion(
+        os.path.join(root_dir, "completions/zsh/_git-remote-gcrypt"), comp_commands
+    )
+    update_fish_completion(
+        os.path.join(root_dir, "completions/fish/git-remote-gcrypt.fish"), comp_commands
+    )
+
     print("Completions updated.")
 
+
 if __name__ == "__main__":
     main()