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

umpf: add built-in support for synchronizing topic branches #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a3f
Copy link
Member

@a3f a3f commented Jan 25, 2025

While umpf was explicitly developed with multiple developers adding utags and sharing topic branches in mind, it is less than ideal when there are multiple developers working on the same topic branches.

And it frequently leads to one of two issues:

  • The branch is pushed before the utag is accepted into the BSP repository and other developers get an unexpected addition to their umpf

  • The branch is not pushed after the utag is accepted into the BSP repository and other developers get an unexpected removal from their umpf

Every time this happens, it wastes a bit of time to identify what went wrong and thus a solution built into umpf is appropriate:

  • CI will call umpf --remote=downstream --force push $BSP/series.inc when a PR touching a useries is accepted

  • Developers can call umpf pull to synchronize their topic branches or to find out when difference they have to the now upstream version

@a3f a3f force-pushed the afa/umpf-push-pull-legs branch from 9f35a0f to 4353753 Compare January 25, 2025 10:09
While umpf was explicitly developed with multiple developers adding
utags and sharing topic branches in mind, it is less than ideal when
there are multiple developers working on the same topic branches.

And it frequently leads to one of two issues:

  - The branch is pushed before the utag is accepted into the BSP
    repository and other developers get an unexpected addition to
    their umpf

  - The branch is not pushed after the utag is accepted into the BSP
    repository and other developers get an unexpected removal from
    their umpf

Every time this happens, it wastes a bit of time to identify what went
wrong and thus a solution built into umpf is appropriate:

  - CI will call umpf --remote=downstream --force push $BSP/series.inc
    when a PR touching a useries is accepted

  - Developers can call umpf pull to synchronize their topic branches
    or to find out when difference they have to the now upstream
    version

Signed-off-by: Ahmad Fatoum <[email protected]>
@a3f a3f force-pushed the afa/umpf-push-pull-legs branch from 4353753 to b48609e Compare January 25, 2025 10:17
Copy link
Member

@michaelolbrich michaelolbrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this in general. A lot of small stuff, and as noted below, I think you can remove the local special case.

### command: push ###

resolve_commitish() {
${GIT} rev-parse --revs-only "$@" 2>/dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ${..} everywhere.

}

shorten_commitish() {
resolve_commitish --short ${1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote arguments everywhere.


update_local() {
local success=false args="${1}"
local opts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an array for opts.

while read -r line; do
local prefix="" suffix=""

eval set -- ${line}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local a b c
read -r a b c <<< "${line}"

Use better variable names but you get the idea. This avoids other expansions.

Or use read -r -a array_var ... but I think individual variables make this more readable,

done <<< "$args"

while read -r line; do
eval set -- ${line}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines +1980 to +1989
local rtagrev="$(resolve_tag "${remote}" ${tagname})"
local rtagrevf="$(resolve_commitish ${rtagrev}^)"
if [ "$tagrevf" != "$rtagrevf" ]; then
if [ -z "$rtagrevf" ]; then
abort "${remote}${remote:+/}refs/tags/$tagname not found"
else
abort "${remote}${remote:+/}refs/tags/$tagname" \
"has unexpected commit-ish $rtagrev"
fi
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip for emtpy remote? In that case you're comparing the same tag, right?

fi

local rtagrev="$(resolve_tag "${remote}" ${tagname})"
local rtagrevf="$(resolve_commitish ${rtagrev}^)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use resolve_tag here as well to make it less confusing.

commit="refs/tags/$tag"
fi

resolve_commitish "${commit}^{}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to compare the local and remote tags. What's the use-case for accepting different tags with the same commit?

return
fi

${GIT} push $opts ${remote} -- $args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, if you use ${GIT_DIR} as remote for the local case, you can use git push for that as well. That would avoid a lot of complexity. So try that first, it may make some of my comments obsolete.


if [ -n "${remote}" ]; then
# Needed, so git rev-parse below can check for existent branches
git fetch --quiet --no-tags ${remote} 2>/dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, use ls-remote for the branch checks instead.

That would make a --force-with-lease possible as well (I'd like to see that as well at some point but I won't insist on it for this PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants