File size: 766 Bytes
fbf3c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
id: docs
title: Docs & Changelog
author: admin
description: Generate changelog and update README snippets.
version: 0.1.0
license: Proprietary
"""

import subprocess
import io


class Tools:
    def changelog(
        self, repo: str = "/data/adaptai/projects/oui-max", max_lines: int = 200
    ) -> dict:
        cmd = f"git -C {repo} log --oneline -n {max_lines}"
        p = subprocess.run(["bash", "-lc", cmd], capture_output=True, text=True)
        return {"stdout": p.stdout, "stderr": p.stderr, "exit_code": p.returncode}

    def update_readme_append(self, repo: str, text: str) -> dict:

        p = f"{repo}/README.md"
        with io.open(p, "a", encoding="utf-8") as f:
            f.write("\n" + text + "\n")
        return {"ok": True, "path": p}