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

Remove user parameter from add_changelog_entry and always use bci-internal #1775

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
> Command | Description
> --- | ---
> /help | Print this message
> /vc user=$user [packages=$pkg] $changelog_entry | Appends the given changelog entry as the provided user to the packages in the current branch.
> /vc [packages=$pkg] $changelog_entry | Appends the given changelog entry to the packages in the current branch.
5 changes: 0 additions & 5 deletions .github/workflows/vc-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ jobs:
[[ "$branch" =~ ^SUSE:for-deploy- ]]
export OS_VERSION="${branch/SUSE:for-deploy-/}"

user="${{ github.event.client_payload.slash_command.args.named.user }}"
if [[ -z "$user" ]]; then echo "Missing user parameter!"; exit 1; fi
export user

entry="${{ github.event.client_payload.slash_command.args.unnamed.all }}"
if [[ -z "$entry" ]]; then echo "No changelog entry provided!"; exit 1; fi
export entry
Expand All @@ -54,7 +50,6 @@ jobs:
poetry run scratch-build-bot \
-vvvv --os-version $OS_VERSION \
add_changelog_entry \
--user $user \
"$entry"
env:
OSC_PASSWORD: ${{ secrets.OSC_PASSWORD }}
Expand Down
32 changes: 16 additions & 16 deletions src/staging/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@
#: environment variable from which the password of the bot's user is taken
OSC_PASSWORD_ENVVAR_NAME = "OSC_PASSWORD"

#: full name of the bot account performing git actions
GIT_COMMITTER_NAME = "SUSE Update Bot"

#: email address of the bot account performing git actions
GIT_COMMITTER_EMAIL = "[email protected]"

_GIT_COMMIT_ENV = {
"GIT_COMMITTER_NAME": "SUSE Update Bot",
"GIT_COMMITTER_EMAIL": "[email protected]",
"GIT_COMMITTER_NAME": GIT_COMMITTER_NAME,
"GIT_COMMITTER_EMAIL": GIT_COMMITTER_EMAIL,
}

#: tuple of OsVersion that need the base container to be linked into the staging
Expand Down Expand Up @@ -1361,13 +1367,11 @@ def _recurse_search_for_ancestor(
return res - {ancestor_commit}

async def add_changelog_entry(
self, entry: str, username: str, package_names: list[str] | None
self, entry: str, package_names: list[str] | None
) -> str:
target_branch_name = f"for-deploy-{self.os_version}"
entry = entry.replace('"', r"\"")

user = await self._fetch_user(username)

if not package_names:
commits = self._get_commit_range_between_refs(
f"origin/{target_branch_name}", f"origin/{self.deployment_branch_name}"
Expand Down Expand Up @@ -1404,7 +1408,10 @@ async def _add_changelog_in_worktree(worktree_dir: str) -> bool:
tasks.append(
run_in_worktree(
f'/usr/lib/build/vc -m "{entry}" {package_name}.changes',
env={"VC_REALNAME": user.realname, "VC_MAILADDR": user.email},
env={
"VC_REALNAME": GIT_COMMITTER_NAME,
"VC_MAILADDR": GIT_COMMITTER_EMAIL,
},
cwd=os.path.join(worktree_dir, package_name),
)
)
Expand All @@ -1422,8 +1429,8 @@ async def _add_changelog_in_worktree(worktree_dir: str) -> bool:
f"git commit -m '{commit_msg}'",
env={
**_GIT_COMMIT_ENV,
"GIT_AUTHOR_NAME": user.realname,
"GIT_AUTHOR_EMAIL": user.email,
"GIT_AUTHOR_NAME": GIT_COMMITTER_NAME,
"GIT_AUTHOR_EMAIL": GIT_COMMITTER_EMAIL,
**os.environ,
},
)
Expand Down Expand Up @@ -1684,12 +1691,6 @@ def add_commit_message_arg(p: argparse.ArgumentParser) -> None:
"add_changelog_entry",
help="Add a changelog entry to the specified packages to the 'for-deploy-$deploment_branch' branch",
)
changelog_parser.add_argument(
"--user",
nargs=1,
type=str,
help="The OBS user as who the changelog entry shall be made",
)
_PACKAGES_ARG_ENV_VAR = "PACKAGES"
changelog_parser.add_argument(
"--packages",
Expand Down Expand Up @@ -1861,7 +1862,6 @@ async def _quality():

elif action == "add_changelog_entry":
changelog_entry = " ".join(args.entry)
username = args.user[0]
pkg_names = None
if (packages_len := len(args.packages)) == 1:
if pkgs_csv := args.packages[0]:
Expand All @@ -1870,7 +1870,7 @@ async def _quality():
pkg_names = args.packages

coro = bot.add_changelog_entry(
entry=changelog_entry, username=username, package_names=pkg_names
entry=changelog_entry, package_names=pkg_names
)

elif action == "changelog_check":
Expand Down