Skip to content

Commit

Permalink
Change the logic for --commit, it's not necessary to create a new bra…
Browse files Browse the repository at this point in the history
…nch for every commit.

Adds --branch for the old --commit logic.
  • Loading branch information
Odilhao committed Mar 27, 2023
1 parent 17a16d6 commit 8e6cf91
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM quay.io/centos/centos:stream8

RUN echo "tsflags=nodocs" >> /etc/yum.conf && \
yum -y install git glibc-langpack-en epel-release python3-pip && \
yum clean all
dnf -y install git glibc-langpack-en epel-release python3-pip dnf-utils && \
dnf clean all

ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
Expand Down
9 changes: 8 additions & 1 deletion obal/data/playbooks/update/metadata.obal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ help: |
obal update mypackage --version 3.4.5
To update a package to a new version and create a git branch for the change from the command line:
To update a package to a new version and create a commit for the change from the command line:
obal update mypackage --version 3.4.5 --commit
To update a package to a new version and create a git branch for the change from the command line:
obal update mypackage --version 3.4.5 --branch
Updating a package that is taken from an upstream repository assumes that the package_manifest already defines the upstream location. Thus, the command line to update to a newer version that is available upstream automatically is:
obal update mypackage
Expand All @@ -25,5 +29,8 @@ variables:
changelog:
help: Optionally set the changelog. When unspecified, an entry will be generated
commit:
help: When true, commits the update changes to it into the current branch
action: store_true
branch:
help: When true, creates a git branch and commits the update changes to it.
action: store_true
18 changes: 17 additions & 1 deletion obal/data/playbooks/update/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,25 @@
when:
- "'://' not in item"

- name: 'Get updated version from spec'
command: "rpmspec --query --queryformat=%{version} --srpm {{ spec_file_path }}"
args:
chdir: "{{ inventory_dir }}"
changed_when: false
register: updated_version
when: commit is defined and commit

- name: 'Create git commit'
command: "git commit -a -m 'Update {{ inventory_hostname }} to {{ updated_version.stdout }}'"
args:
chdir: "{{ inventory_dir }}"
run_once: true
changed_when: true
when: commit is defined and commit

- hosts:
- packages
gather_facts: false
roles:
- when: commit is defined and commit
- when: branch is defined and branch
role: git_branch_and_commit
10 changes: 8 additions & 2 deletions tests/fixtures/help/update.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
usage: obal update [-h] [-v] [-e EXTRA_VARS] [--changelog CHANGELOG]
[--commit] [--prerelease PRERELEASE] [--release RELEASE]
[--branch] [--commit] [--prerelease PRERELEASE] [--release RELEASE]
[--version VERSION]
target [target ...]

Expand All @@ -13,6 +13,10 @@ To update a package to a new version from the command line:

To update a package to a new version and create a git branch for the change from the command line:

obal update mypackage --version 3.4.5 --branch

To update a package to a new version and create a commit for the change from the command line:

obal update mypackage --version 3.4.5 --commit

Updating a package that is taken from an upstream repository assumes that the package_manifest already defines the upstream location. Thus, the command line to update to a newer version that is available upstream automatically is:
Expand All @@ -28,8 +32,10 @@ optional arguments:
--changelog CHANGELOG
Optionally set the changelog. When unspecified, an
entry will be generated
--commit When true, creates a git branch and commits the update
--branch When true, creates a git branch and commits the update
changes to it.
--commit When true, commits the update changes to it into the
current branch
--prerelease PRERELEASE
Optionally set the prerelease macro. When unspecified,
the prerelease macro will be removed
Expand Down

0 comments on commit 8e6cf91

Please sign in to comment.