-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
3da14fa
to
a4874a1
Compare
Add manual mode:
Now i can do:
Maybe it's an overkill, but it makes porting easier for me. |
@gmelikov thanks, this looks really useful and your manual mode looks ideal for the use case I have in mind. Once we're largely caught up with the OpenZFS tree we're going to want to automate this process as much as possible. As you know this won't work for all commits, but there will be a subset of commits which do apply cleanly. Using your manual mode we'd love to be able to script some version the following which runs when a new commit gets merged to OpenZFS.
Since you've already implemented the majority of this I think the only missing bit is the ability to open a new PR. The good news here is that there's already an existing utility provided by GitHub which does this called hub. It's a wrapper which extends to git command to support things like opening PRs from the command line. If you can add this functionality to the script we should have everything we need. Thanks for working on this! |
@behlendorf thanks for straightforward usecase. I'll add this functionality little later, because while improving script i'm ready to check new commits by myself. But it's the best approach, i agree. Main problems with auto merge:
|
This should be handled by git in the majority of cases. There are going to be a couple of files which it can't match because they've been either rewritten entirely for Linux (vdev_disk.c, zvol.c, zfs_ctldir.c) or currently only exist under Linux (zpl_.c, vdev_raidz_math.c). Have you noticed other files which can't me matched?
Agreed, that's the best we can do. I'm not opposed to applying patches to the Linux port which are just designed to minimize these tiny differences.
Yes, we should grab the rewritten mdoc pages from Illumos as a starting point and then re-apply the Linux specific sections we've added. This would also be a good time to feed trivial fixes for spelling mistakes and such back upstream to OpenZFS. |
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.
Thanks for opening this pull request! Really excited about adding this to our set of scripts. Just a few comments looking at it. I'll be trying to use the script this afternoon and will post any other feedback.
-d directory Git repo with openzfs and zfsonlinux remotes | ||
-i commits.txt File with OpenZFS commit hashes to merge | ||
(one hash per row) | ||
-i commit hash Prepare branch and try to merge this commit by hash, |
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 you meant -c
here.
rm "$TMP_FILE" | ||
git checkout master | ||
git fetch --all | ||
git log --remotes=openzfs/master --format=%B -n 1 $OPENZFS_COMMIT > "$TMP_FILE" |
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.
Is --remotes
necessary here? The commit hash should be sufficient to find the log entry.
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.
It's just for safety, we use short hashes.
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
REPOSITORY_PATH='.' | ||
TMP_FILE='/tmp/gittmpmessage.txt' |
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 you are using a file because it is easier to work with? If so, then this fine.
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.
Yes, it was just easier for me.
fi | ||
|
||
echo -e "${LGREEN} Cstyle... ${NORMAL}" | ||
if ! make cstyle; then |
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'm not sure if you should fail if cstyle fails. The patch may work and would involve minor tweaking to address the style problems. Thoughts?
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.
It may be appropriate to add a flag to the script to control this behavior.
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 thought in this way: patch have to be edited -> fail, overwise success.
Yes, it's easy to add a flag, i'll add it.
@@ -81,6 +81,8 @@ OPTIONS: | |||
-h Show this message | |||
-d directory Git repo with openzfs and zfsonlinux remotes | |||
-e exceptions Exception file (using ZoL wiki if not specified) | |||
-c file.txt Write OpenZFS unmerged commits' hashes to file, |
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.
Tabbing/Spacing needs to be fixed here.
@@ -234,7 +239,7 @@ do | |||
|
|||
# Match issue against any open pull requests. | |||
ZFSONLINUX_PR=$(echo $ZFSONLINUX_PRS | jq -r ".[] | select(.title | \ | |||
contains(\"OpenZFS $OPENZFS_ISSUE\")) | { html_url: .html_url }" | \ | |||
contains(\"OpenZFS $OPENZFS_ISSUE \")) | { html_url: .html_url }" | \ |
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.
A rebase should get rid of this change.
# | ||
# Repository setup for valid compilation check: | ||
# sh autogen.sh | ||
# ./configure --enable-debug |
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.
Wouldn't it be safe to run sh autogen.sh
and ./configure
for each commit? Is it because Makefile.in's don't often change? There are other .in files as well.
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.
It will we safer, but much more slower.
I didn't have any issues with it yet.
|
||
clean_unmerged() { | ||
git cherry-pick --abort | ||
git checkout master |
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.
It may be worth documenting that this script should be used on a clone where the origin is a fork of ZFS on Linux that has a remote to OpenZFS.
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.
There are already these lines:
# Repository setup must be similar with openzfs-tracking.sh
# requirements.
openzfs-tracking.sh already has there requirements.
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.
Ah, I missed that. Thanks.
git cherry-pick --abort | ||
git checkout master | ||
git branch -D "autoport-oz$OPENZFS_ISSUE" | ||
rm "$TMP_FILE" |
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.
You may want to run a git clean -xdf
. This would require you to rerun sh autogen.sh
and ./configure
.
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.
Maybe, but this variant is faster and it won't remove untracked files.
|
||
echo -e "${LGREEN} - OpenZFS issue #$OPENZFS_ISSUE $OPENZFS_COMMIT ${NORMAL}" | ||
echo -e "${LGREEN} Checkout new branch ${NORMAL}" | ||
git branch -D "autoport-oz$OPENZFS_ISSUE" |
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.
You may want to change this to git branch -D "autoport-oz$OPENZFS_ISSUE" > /dev/null
because it displays an error if the branch doesn't exist.
OPENZFS_COMMIT_AUTHOR=$(git log --format="%aN <%aE>" --remotes=openzfs/master -n 1 $OPENZFS_COMMIT) | ||
|
||
sed -i '1s/^/OpenZFS /' "$TMP_FILE" | ||
sed -i 's/ / - /2' "$TMP_FILE" |
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 believe this string replace intends to add a dash after the issue number, but it ends up putting dashes after each Reviewed by:
. Also, it's not spaced correctly. Here's what I came up with:
generate_desc() {
USER_NAME=$(git config user.name)
USER_MAIL=$(git config user.email)
OPENZFS_COMMIT_AUTHOR=$(git log --format="%aN <%aE>" --remotes=openzfs/master -n 1 $OPENZFS_COMMIT)
OPENZFS_ISSUE=$(grep -oP '^[^0-9]*\K[0-9]+' -m 1 "$TMP_FILE")
sed -i "1s/^$OPENZFS_ISSUE/OpenZFS $OPENZFS_ISSUE -/" "$TMP_FILE"
sed -i "1 a Authored by: $OPENZFS_COMMIT_AUTHOR" "$TMP_FILE"
sed -i '/^$/d' "$TMP_FILE"
sed -i "/^OpenZFS $OPENZFS_ISSUE.*$/G" "$TMP_FILE"
echo 'Ported-by: '$USER_NAME' <'$USER_MAIL'>' >> "$TMP_FILE"
echo '' >> "$TMP_FILE"
echo 'OpenZFS-issue: https://www.illumos.org/issues/'$OPENZFS_ISSUE >> "$TMP_FILE"
echo 'OpenZFS-commit: https://github.com/openzfs/openzfs/commit/'$OPENZFS_COMMIT >> "$TMP_FILE"
}
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.
Thanks, fixed this problem.
@behlendorf just have examples for different paths:
I think that's because these files are reworked for Linux, so this commit may be unmergable. |
So in this case the |
@gmelikov let's get this merged as an initial version of the script. Do you have any additional fixes yould like to make first? |
@behlendorf i don't have any for now, so let's merge it. Thanks for review! |
This script can:
openzfs-tracking.sh
now can generate text files with unmerged OpenZFS commits, if add-c
parameter.We can post them on website too for easier auto merge process.
This is a fast written draft, welcome any thoughts. I think it will be better to wait some time before merge it.
I tested it, you can see last PRs from my
autoport
branches.Unfourtunately, there is no suitable to auto merge commit, you can add openzfs/openzfs@9185393 to hashes file manually.
Based on #50.