roundabout,
created on Sunday, 25 February 2024, 08:13:51 (1708848831),
received on Wednesday, 31 July 2024, 06:54:41 (1722408881)
Author identity: vlad <vlad.muntoiu@gmail.com>
54ec15e49bddb0051e114d08b258fba2a51e4c28
celery_tasks.py
@@ -7,6 +7,7 @@ from app import db
from misc_utils import * from models import * from smtplib import SMTP from celery.utils.log import get_task_logger@shared_task(ignore_result=False)
@@ -41,16 +42,16 @@ def merge_heads(head_route, head_branch, base_route, base_branch, simulate=True)
if base_route == head_route: git_command(server_repo_location, b"", "checkout", f"{base_branch}") if simulate: out, err = git_command(server_repo_location, b"", "merge", "--no-commit", "--no-ff", f"heads/{head_branch}",return_err=True)out, err, merge_exit = git_command(server_repo_location, b"", "merge", "--no-commit", "--no-ff", f"heads/{head_branch}", return_err=True, return_exit=True)# Undo the merge. git_command(server_repo_location, b"", "merge", "--abort") else: out, err = git_command(server_repo_location, b"", "merge", f"heads/{head_branch}",return_err=True)out, err, merge_exit = git_command(server_repo_location, b"", "merge", f"heads/{head_branch}", return_err=True, return_exit=True)return "merge_simulator" if simulate else "merge", out, err, head_route, head_branch, base_route, base_branchreturn "merge_simulator" if simulate else "merge", out, err, head_route, head_branch, base_route, base_branch, merge_exitremote_url = os.path.join(config.BASE_DOMAIN, "git", base_route.lstrip("/"))
@@ -65,11 +66,14 @@ def merge_heads(head_route, head_branch, base_route, base_branch, simulate=True)
out += part_out err += part_err if simulate: part_out, part_err = git_command(server_repo_location, b"", "merge", "--allow-unrelated-histories","--no-commit", "--no-ff", f"NEW/{head_branch}", return_err=True)part_out, part_err, merge_exit = git_command(server_repo_location, b"", "merge", "--allow-unrelated-histories", "--no-commit", "--no-ff", f"NEW/{head_branch}", return_err=True, return_exit=True)else: part_out, part_err = git_command(server_repo_location, b"", "merge", "--allow-unrelated-histories",f"NEW/{head_branch}", return_err=True)part_out, part_err, merge_exit = git_command(server_repo_location, b"", "merge", "--allow-unrelated-histories", f"NEW/{head_branch}", return_err=True, return_exit=True) diff, diff_exit = git_command(server_repo_location, b"", "diff", "--check", return_exit=True)out += part_out err += part_err part_out, part_err = git_command(server_repo_location, b"", "remote", "rm", "NEW", return_err=True)
@@ -79,4 +83,4 @@ def merge_heads(head_route, head_branch, base_route, base_branch, simulate=True)
# Undo the merge. git_command(server_repo_location, b"", "merge", "--abort") return "merge_simulator" if simulate else "merge", out, err, head_route, head_branch, base_route, base_branchreturn "merge_simulator" if simulate else "merge", out, err, head_route, head_branch, base_route, base_branch, merge_exit
misc_utils.py
@@ -4,7 +4,7 @@ import magic
from models import * def git_command(repo, data, *args, return_err=False):def git_command(repo, data, *args, return_err=False, return_exit=False):if not os.path.isdir(repo): raise FileNotFoundError(f"Repo {repo} not found") env = os.environ.copy()
@@ -18,10 +18,16 @@ def git_command(repo, data, *args, return_err=False):
proc.stdin.write(data) out, err = proc.communicate() exit_code = proc.returncode result = (out,)if return_err: return out, errresult = result + (err,) if return_exit: result = result + (exit_code,)return outreturn result[0] if len(result) == 1 else resultdef only_chars(string, chars):
static/style.css
@@ -5,6 +5,12 @@
--color-branch-text: var(--color-primary-1-text); --color-tag: var(--color-accent-1); --color-tag-text: var(--color-accent-1-text); --color-pending: #4caf50; --color-pending-text: #ffffff; --color-rejected: #ff9800; --color-rejected-text: #ffffff; --color-merged: #9c27b0; --color-merged-text: #ffffff;} .big-button {
@@ -202,4 +208,11 @@ hr {
border-width: 1px; margin: 1em 0; opacity: 0.5; } .state-label { writing-mode: vertical-lr; text-transform: uppercase; padding: 1em; margin: 0;}
templates/repository/repo-prs.html
@@ -30,6 +30,19 @@
<x-vbox> {% for pr in repo_data.bases %} <article class="card card-horizontal"> {% if pr.state == 0 %} <div class="card-top state-label" style="background: var(--color-pending); color: var(--color-pending-text);"> pending </div> {% elif pr.state == 1 %} <div class="card-top state-label" style="background: var(--color-merged); color: var(--color-merged-text);"> merged </div> {% elif pr.state == 2 %} <div class="card-top state-label" style="background: var(--color-rejected); color: var(--color-rejected-text);"> rejected </div> {% endif %}<section class="card-main flexible-space"> <h3>{{ pr.head_route }} ({{ pr.head_branch }})<br>{{ pr.base_route }} ({{ pr.base_branch }})</h3> <p>Requested by <a href="/{{ pr.owner.username }}">{{ pr.owner.username }}</a> • {{ pr.timestamp | strftime("%A, %e %B %Y, %H:%M:%S") }}</p>
templates/task-monitor.html
@@ -18,6 +18,7 @@
Running... {% endif %} </x-hbox> {% if result.get()[0] == "merge_simulator" %} {% if result.get()[1] %} <h2>Info</h2>
@@ -27,8 +28,9 @@
<h2>Errors</h2> <pre aria-busy="true" aria-describedby="task-progress">{{ result.get()[2] | decode }}</pre> {% endif %} {% if result.get()[1] or result.get()[2] and not result.get()[2].decode().startswith("Automatic merge went well") %}<h2>Cannot merge your branches :/</h2>{% if result.get()[7] %} <h2>Cannot merge your branches</h2><p> Since we can't help you with this yet, you'll need to resolve the merge conflicts on your own computer.