-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: master
Are you sure you want to change the base?
Conversation
9f35a0f
to
4353753
Compare
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]>
4353753
to
b48609e
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
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 |
There was a problem hiding this comment.
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}^)" |
There was a problem hiding this comment.
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}^{}" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
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 acceptedDevelopers can call
umpf pull
to synchronize their topic branches or to find out when difference they have to the now upstream version