flathub-infra / flatpak-external-data-checker

A tool for checking if the external data used in Flatpak manifests is still up to date
GNU General Public License v2.0
115 stars 34 forks source link

main: Set module names as title #429

Closed bbhtt closed 3 months ago

bbhtt commented 4 months ago

Choose the "best" title with most module names while making sure it does not cross 70 characters. The limit is to prevent too much verbosity in commit messages and PR titles when a large set of modules are getting updated.

If it crosses 70 characters, start deducting module names and add the number of remaining updated modules.

bbhtt commented 4 months ago

56 is the max characters Github can hold in the title in a single line. The commit message is probably 70 or 80.

I'd like to keep some form of "backoff" parameter to prevent ugly PR titles.

I convert it to set to avoid duplicate module names see eg. https://github.com/flathub/org.kde.kdenlive/pull/395

wjt commented 4 months ago

Something like this, but preserving the order of changes?

def build_commit_message(changes: t.List[str]) -> str:
    assert len(changes) >= 1

    if len(changes) == 1:
        return changes[0]

    module_names = list({i.split(":", 1)[0] for i in changes})
    for i in reversed(range(2, len(module_names) + 1)):
        print(i)
        xs = module_names[:i - 1]
        y = module_names[i - 1]
        zs = module_names[i:]

        if zs:
            tail = f" and {len(zs)} more"
            xs.append(y)
        else:
            tail = f" and {y}"

        subject = "Update " + ", ".join(xs) + tail
        if len(subject) <= 56:
            return subject

    return f"Update {len(changes)} modules"
bbhtt commented 4 months ago

If you want to preserve the order in the list only there might be some shorter way I'll check soon.

list({i.split(":", 1)[0] for i in changes})

This doesn't preserve order of changes

bbhtt commented 4 months ago

Pushed something that will preserve order. The rest of the formatting I don't have opinions about. But if you can give me it as a patch I can preserve authorship.

bbhtt commented 4 months ago

Also how about adding Update: a, b and n more *modules* ? As these aren't sources necessarily a single module can have multiple sources with checker data associated.

bbhtt commented 3 months ago

But if you can give me it as a patch I can preserve authorship.

@wjt Would you prefer that I finish this?

wjt commented 3 months ago

Sure, I don't mind about authorship!

bbhtt commented 3 months ago

Done

bbhtt commented 3 months ago

I changed the limit to 70 characters to allow more module names in the title.