Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-latest-version.py: Random suffix for bot branch name #308

Open
ryonakano opened this issue Mar 1, 2025 · 0 comments
Open

get-latest-version.py: Random suffix for bot branch name #308

ryonakano opened this issue Mar 1, 2025 · 0 comments
Labels
Priority: Wishlist New feature or request. Not a priority, but something that might be nice.

Comments

@ryonakano
Copy link
Member

Problem

The branch name that get-latest-version.py creates is not unique:

new_branch = f"bot/update/{component_name}-{upstream_series_name}"

So, the actions will fail if the previous branch remains for some reason, e.g. closed the PR without deleting the branch or when Automatically delete head branches is not enabled:

Run python3 get-latest-version.py "noble"
  python3 get-latest-version.py "noble"
  shell: sh -e {0}
  env:
    PACKAGES_TO_IMPORT_PATH: /tmp/patched-packages
    GITHUB_TOKEN: ***
    GITHUB_REPOSITORY: os-patches
Traceback (most recent call last):
base-files noble
  File "/__w/os-patches/os-patches/get-latest-version.py", line 168, in <module>
  File "/__w/os-patches/os-patches/get-latest-version.py", line 157, in main
bash noble
distro-info-data noble
dpkg-source: info: extracting distro-info-data in distro-info-data-0.60ubuntu0.2
  File "/usr/lib/python3/dist-packages/git/cmd.py", line 739, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/git/cmd.py", line 1315, in _call_process
    return self.execute(call, **exec_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/git/cmd.py", line 1110, in execute
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git push origin bot/update/distro-info-data-noble
  stderr: 'To https://github.com/ryonakano/os-patches
 ! [rejected]            bot/update/distro-info-data-noble -> bot/update/distro-info-data-noble (non-fast-forward)
error: failed to push some refs to 'https://github.com/ryonakano/os-patches'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.'
Error: Process completed with exit code 1.

Proposal

Add random string to branch names and make sure the actions won't fail even if the previous branch remains.

Prior Art (Optional)

  • Flatpak External Data Checker puts random suffix, e.g. update-f7b567c:
    Image
@ryonakano ryonakano added the Priority: Wishlist New feature or request. Not a priority, but something that might be nice. label Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Wishlist New feature or request. Not a priority, but something that might be nice.
Projects
None yet
Development

No branches or pull requests

1 participant