Skip to content

Commit

Permalink
Split git setup to multiple macros
Browse files Browse the repository at this point in the history
Configuration requirements for `git` and `git_am` can be different
enough so that that these two should not share the setup routine
in it's entirety [1]. On the other hand, some parts of the setup
can (and should) be kept same in both approaches.

[1]: #3472

This splits the `%__scm_setup_git` macro into several named steps,
which are then combined as needed. It also implements the first
difference between `git` and `git_am` – the author is no longer
configured when using `git_am`.
  • Loading branch information
khardix committed Dec 3, 2024
1 parent fe9a914 commit 5f6f6b8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -1239,25 +1239,42 @@ Supplements: (%{name} = %{version}-%{release} and langpacks-%{1})\
%__scm_source_timestamp @${SOURCE_DATE_EPOCH:-${RPM_BUILD_TIME:?}}

# Git
%__scm_setup_git(q)\
%__scm_init_git(q)\
%{__git} init %{-q}\

%__scm_configure_git\
%{__git} config user.name "%{__scm_username}"\
%{__git} config user.email "%{__scm_usermail}"\
%{__git} config gc.auto 0\
%{__git} config user.email "%{__scm_usermail}"

%__scm_configure_git_common\
%{__git} config gc.auto 0

%__scm_import_git(q)\
%{__git} add --force .\
GIT_COMMITTER_DATE=%{__scm_source_timestamp} GIT_AUTHOR_DATE=%{__scm_source_timestamp}\\\
%{__git} commit %{-q} --allow-empty -a\\\
--author "%{__scm_author}" -m "%{NAME}-%{VERSION} base"\
%{__git} checkout --track -b rpm-build

%__scm_setup_git(q)\
%{expand:%__scm_init_git %{-q}}\
%{expand:%__scm_configure_git}\
%{expand:%__scm_configure_git_common}\
%{expand:%__scm_import_git %{-q}}

%__scm_apply_git(qp:m:)\
%{__git} apply --index --reject %{-p:-p%{-p*}} -\
GIT_COMMITTER_DATE=%{__scm_source_timestamp} GIT_AUTHOR_DATE=%{__scm_source_timestamp}\\\
%{__git} commit %{-q} -m %{-m*} --author "%{__scm_author}"

# Git, using "git am" (-m is unused)
%__scm_configure_git_am %{nil}

%__scm_setup_git_am(q)\
%{expand:%__scm_setup_git %{-q}}
%{expand:%__scm_init_git %{-q}}\
%{expand:%__scm_configure_git_am}\
%{expand:%__scm_configure_git_common}\
%{expand:%__scm_import_git %{-q}}

%__scm_apply_git_am(qp:m:)\
GIT_COMMITTER_DATE=%{__scm_source_timestamp}\\\
Expand Down

0 comments on commit 5f6f6b8

Please sign in to comment.