Skip to content

Add pr forward command to git-obs#2050

Open
fwag wants to merge 18 commits intomasterfrom
feature/pr_forward
Open

Add pr forward command to git-obs#2050
fwag wants to merge 18 commits intomasterfrom
feature/pr_forward

Conversation

@fwag
Copy link
Collaborator

@fwag fwag commented Feb 13, 2026

Automates the workflow of forwarding sources from one branch to another (e.g., Factory to Leap/SLFO) via a PR.

The command handles:

  • Automatic forking of the target repository if it doesn't exist.
  • Smart workspace detection and cloning.
  • Syncing the target branch with upstream.
  • Merging the source branch using the 'theirs' strategy.
  • Cleaning up files not present in the source branch to ensure a clean forward.
  • Optimized LFS fetching for specific incoming commits.
  • Force pushing the synchronized state to the fork and opening the Pull Request.

@AdamMajer
Copy link
Member

AdamMajer commented Feb 16, 2026

Why not "just" create PR from /pool#forward to /pool#slfo? This should be AGit created PR because we do not want branch following here anyway. And using consistent context allows for the PR to be updated by repeating the command if the source is updated.

syntax and implementation:

git-obs pr create (src) (destination)
     git clone ...
     git push ...

Ideally, this needs to also work via UI.

# and fetch LFS objects for them from the appropriate remote.
lfs_remote = "source" if source_url else "upstream"
print(f"Fetching LFS objects from {lfs_remote} for incoming commits ...", file=sys.stderr)

Copy link
Member

Choose a reason for hiding this comment

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

If the repo from source to target is the same (different branch), there should be no need to move LFS objects around.

Copy link
Collaborator Author

@fwag fwag Feb 16, 2026

Choose a reason for hiding this comment

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

In this case, there are two repositories: the user's forked repository and the pool repository. Normal users cannot create a PR in pool because they don't have the right permissions.

@fwag
Copy link
Collaborator Author

fwag commented Feb 16, 2026

hi @AdamMajer,
In many cases, you have unrelated histories and need to perform a local merge. Currently, only fast-forward PRs are allowed. This command implements the "theirs" merging strategy and cleaning. Additionally, it allows you to take changes from one Gitea instance and forward them to another.

@hramrach
Copy link
Contributor

There are multiple problems with this from an UX point of view.

  • requires a lot of disk space (compared to 0 of osc SR)
  • leaves litter around (the previously cloned repositories)
  • randomly resets some branches that may or may not contain previous work

Copy link

@janvhs janvhs left a comment

Choose a reason for hiding this comment

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

I initially asked the question in the slack channel. I used this today to submit factory to slfo-main for gnuplot. Thank for writing this so quickly, it really reduces the overhead and potential mistakes associated with it. I added a few code comments with general thoughts and suggestions.

Overall I wish there was a solution which I wouldn't need to clone the repo for, but this is a great improvement. Thank you!


There is a bunch of trailing white space in the file.

# Fork if not exists
print(f"Checking fork for {upstream_owner}/{upstream_repo} ...", file=sys.stderr)
try:
fork_obj = gitea_api.Fork.create(self.gitea_conn, upstream_owner, upstream_repo)

This comment was marked as resolved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If your "factory" branch is out of sync between your local git and the remote fork, git will block your push. That's why I added the --force parameter. In any case, using a temporary branch is a good idea.


print("Creating Pull Request ...", file=sys.stderr)
try:
pr_obj = gitea_api.PullRequest.create(

This comment was marked as resolved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok added --edit, commit message is automatically created from PR title and PR description

if not os.path.exists(repo_dir):
os.makedirs(repo_dir)
else:
repo_dir = tempfile.mkdtemp(prefix="git-obs-forward-")

This comment was marked as off-topic.

@janvhs
Copy link

janvhs commented Feb 17, 2026

leaves litter around (the previously cloned repositories)

+1 to your feedback, but it cleans up the working directory, except when you pass --no-cleanup to the command.

@janvhs
Copy link

janvhs commented Feb 17, 2026

Regarding the white space:

From 74f8f8aba15141b73095aca7aa1a2801a23e5558 Mon Sep 17 00:00:00 2001
From: Jan Fooken <jan.fooken@suse.com>
Date: Tue, 17 Feb 2026 16:47:55 +0100
Subject: [PATCH] Remove whitespace

---
 osc/commands_git/pr_forward.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/osc/commands_git/pr_forward.py b/osc/commands_git/pr_forward.py
index 176dd1c3..6a0ba653 100644
--- a/osc/commands_git/pr_forward.py
+++ b/osc/commands_git/pr_forward.py
@@ -88,7 +88,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
         upstream_repo_obj = gitea_api.Repo.get(self.gitea_conn, upstream_owner, upstream_repo)
         fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)
 
-        upstream_url = upstream_repo_obj.ssh_url 
+        upstream_url = upstream_repo_obj.ssh_url
         fork_url = fork_repo_obj.ssh_url # Prefer SSH for push if possible
 
         # Setup Workdir
@@ -149,7 +149,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
                     git.add_remote("source", source_url)
                 else:
                     git._run_git(["remote", "set-url", "source", source_url])
-                
+
                 print("Fetching source ...", file=sys.stderr)
                 git.fetch("source")
                 source_ref = f"source/{source_branch}"
@@ -168,11 +168,11 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
             # and fetch LFS objects for them from the appropriate remote.
             lfs_remote = "source" if source_url else "upstream"
             print(f"Fetching LFS objects from {lfs_remote} for incoming commits ...", file=sys.stderr)
-            
+
             try:
                 # Get list of commits unique to source_branch that are not in target_branch
                 commits = git._run_git(["rev-list", f"{lfs_remote}/{source_branch}", f"^{lfs_remote}/{target_branch}"]).splitlines()
-                
+
                 if commits:
                     print(f" * Found {len(commits)} commits to fetch LFS objects for.", file=sys.stderr)
                     # Loop through commits as requested
@@ -204,7 +204,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
 
             # Clean files not in Source
             print("Cleaning files not present in source ...", file=sys.stderr)
-            
+
             # Get list of files in source (recurse)
             source_files_output = git._run_git(["ls-tree", "-r", "--name-only", source_ref])
             source_files = set(source_files_output.splitlines())
@@ -214,7 +214,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
             head_files = set(head_files_output.splitlines())
 
             files_to_remove = list(head_files - source_files)
-            
+
             if files_to_remove:
                 print(f"Removing {len(files_to_remove)} files not present in {source_branch} ...", file=sys.stderr)
                 # Batching git rm to avoid command line length limits
@@ -222,7 +222,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
                 for i in range(0, len(files_to_remove), chunk_size):
                     chunk = files_to_remove[i : i + chunk_size]
                     git._run_git(["rm", "-f", "--"] + chunk)
-                
+
                 git.commit(f"Clean files not present in {source_branch}")
             else:
                 print("No extra files to clean.", file=sys.stderr)
@@ -245,7 +245,7 @@ class PullRequestForwardCommand(osc.commandline_git.GitObsCommand):
             # Create PR
             title = args.title or f"Forward {source_branch} to {target_branch}"
             description = args.description or f"Automated forward of {source_branch} to {target_branch} using git-obs."
-            
+
             if args.dry_run:
                 print(f"[DRY RUN] Would create PR: {title}", file=sys.stderr)
                 return
-- 
2.53.0

@janvhs
Copy link

janvhs commented Feb 18, 2026

Don't really have a repo to test the new changes on, but the changes look good to me.

Linking the branch name with the commit sha means that you can't reuse an already open PR, which I know my colleagues did in the past, but I'm not sure whether that's wanted anyways, nor am I a maintainer here :^)

action="store_true",
help="Allow merging unrelated histories",
)

Copy link
Member

Choose a reason for hiding this comment

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

Please don't forget to add the "--merge" as an option. Creating a PR directly from the source branch to target branch without a merge commit on top should be default.


description = "\n".join(lines).strip()

# Merge Source Branch (Theirs)
Copy link
Member

@AdamMajer AdamMajer Feb 20, 2026

Choose a reason for hiding this comment

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

like above, all this IFF --merge only please.

Comment on lines 293 to 325
merge_cmd = ["merge", "-X", "theirs"]
if args.allow_unrelated_histories:
merge_cmd.append("--allow-unrelated-histories")
merge_cmd.extend(["-m", commit_message, source_ref])
git._run_git(merge_cmd)
except Exception as e:
print(f"{tty.colorize('ERROR', 'red,bold')}: Merge failed: {e}", file=sys.stderr)
sys.exit(1)

# Clean files not in Source
print("Cleaning files not present in source ...", file=sys.stderr)

# Get list of files in source (recurse)
source_files_output = git._run_git(["ls-tree", "-r", "--name-only", source_ref])
source_files = set(source_files_output.splitlines())

# Get list of files in current HEAD
head_files_output = git._run_git(["ls-tree", "-r", "--name-only", "HEAD"])
head_files = set(head_files_output.splitlines())

files_to_remove = list(head_files - source_files)

if files_to_remove:
print(f"Removing {len(files_to_remove)} files not present in {source_branch} ...", file=sys.stderr)
# Batching git rm to avoid command line length limits
chunk_size = 100
for i in range(0, len(files_to_remove), chunk_size):
chunk = files_to_remove[i: i + chunk_size]
git._run_git(["rm", "-f", "--"] + chunk)

git.commit(f"Clean files not present in {source_branch}")
else:
print("No extra files to clean.", file=sys.stderr)
Copy link
Member

Choose a reason for hiding this comment

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

git merge --no-ff --no-commit -X theirs PR_HEAD_SHA
git read-tree -m PR_HEAD_SHA
git commit -m ..
git clean -fxd

The git-read-tree write into the index the info from that other Head and the extra files from current checkout become untracked. Hence need to clean after Merge. But then you no longer need to compare files ... especially since that would ahve to be done recursively.

Copy link
Contributor

Choose a reason for hiding this comment

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

git read-tree -u -m <ref> includes the clean step

Copy link
Member

Choose a reason for hiding this comment

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

git read-tree -u --reset <ref> may be better option, as no merging is done.

I guess we are trying to emulate git merge -s theirs while it doesn't exist.

@mwilck
Copy link
Contributor

mwilck commented Feb 23, 2026

Merging the source branch using the 'theirs' strategy.

I may be missing something, but that's not always correct, is it? My "factory" and "slfo-main" branches tend to have subtle differences, especially a different revision element in the tar_scm service. Wouldn't that be lost with theirs ?

@hramrach
Copy link
Contributor

Merging the source branch using the 'theirs' strategy.

I may be missing something, but that's not always correct, is it? My "factory" and "slfo-main" branches tend to have subtle differences, especially a different revision element in the tar_scm service. Wouldn't that be lost with theirs ?

And how do you expect to merge Factory into other branch if the source revision is not updated?

@mwilck
Copy link
Contributor

mwilck commented Feb 23, 2026

And how do you expect to merge Factory into other branch if the source revision is not updated?

It feels wrong to me to have a revision element in the slfo-main branch that points to factory in the source repo.

I ususally have separate branches for slfo-main and factory in the source repo. More often than not, they point to the same commit, but they don't have to.

@hramrach
Copy link
Contributor

And how do you expect to merge Factory into other branch if the source revision is not updated?

It feels wrong to me to have a revision element in the slfo-main branch that points to factory in the source repo.

I ususally have separate branches for slfo-main and factory in the source repo. More often than not, they point to the same commit, but they don't have to.

This is for the case when you want a branch (git reference) other than factory to point to the same commit, or atleast same content as factory. When that's not what you are looking for you should look elsewhere.

@mwilck
Copy link
Contributor

mwilck commented Feb 24, 2026

This is for the case when you want a branch (git reference) other than factory to point to the same commit, or atleast same content as factory. When that's not what you are looking for you should look elsewhere.

I was confused by the description of the PR, which mentions "theirs" strategy for merging. But there is no "theirs" strategy, there's just "ort" with "theirs" option, and that's what the PR uses. I guess this would "work" for my use case. The different revision tag would be preserved.

The only problem being that If the two source repo commits were not pointing to the same sources, the merge might cause an inconsistent state, as the revision would not match the tarball in the package repo.

And that's why I am not convinced that the automatic merge is a good idea. This functionality makes certain assumptions about how a user has set up his branches in the source repository, and (AFAICS) it contains no safeguards to make sure that this is actually the case. Thus it has the potential to create inconsistent code unless users understand the prerequisites of using the command exactly, which I wouldn't assume.

@hramrach
Copy link
Contributor

How would it cause out of sync result? The merge strategy is the take everything from the new sources, discarding everything in the current sources.

@mwilck
Copy link
Contributor

mwilck commented Feb 24, 2026

How would it cause out of sync result? The merge strategy is the take everything from the new sources, discarding everything in the current sources.

No. -X theirs will use the code from "theirs" if there's a conflict. But in my case, there is no conflict. In the past, I used the "factory" code as base for "slfo-main", and simply changed the revision on the slfo-main branch to point to the slfo-main branch in the source code repo. Unless there's a conflict in _service that affects this specific line, a git merge -X theirs factory will not undo this change.

@hramrach
Copy link
Contributor

So it's implemented incorrectly.

@mwilck
Copy link
Contributor

mwilck commented Feb 24, 2026

So it's implemented incorrectly.

What do you mean, git merge -X theirs or this PR? git merge does exactly what it's supposed to do.

If you want to force-merge, overwriting everything, you need to switch to the other ("theirs") branch, which then becomes "ours", and run git merge -s ours (as opposed to git merge -X ours), switch back to the original branch, and then forward-merge to the result of the merge operation.

@hramrach
Copy link
Contributor

That will create a backwards merge. Not that intelligible history is a concern in git workflow. The commit graphs in the pool repositories looks like barbed wire.

@mwilck
Copy link
Contributor

mwilck commented Feb 24, 2026

That will create a backwards merge. Not that intelligible history is a concern in git workflow. The commit graphs in the pool repositories looks like barbed wire.

Is it important if its backward or forward? That just determines on which side of the merge the history appears. I guess we have to live with the fact that git doesn't support a full "theirs" merge operation.

@mwilck
Copy link
Contributor

mwilck commented Feb 24, 2026

I guess what you could also do is a git merge -X theirs factory followed by something like git diff ..factory | patch -p1 and git commit --amend -a. Pretty clumsy but it should work.

It wouldn't work for me though, because I would want to preserve my change in _service.

@AdamMajer
Copy link
Member

No. -X theirs will use the code from "theirs" if there's a conflict.

Good catch here. Thanks!

git read-tree solves this issues which is what is proposed here.

git merge -X theirs OTHER --no-commit
git read-tree -u -m OTHER
git commit

@AdamMajer
Copy link
Member

We probably could use git read-tree --reset -u OTHER when reading the other branch.

@fwag
Copy link
Collaborator Author

fwag commented Feb 25, 2026

This PR did not consider Martin's use case. The purpose of this PR was mainly to report the exact state of one branch in another.

@AdamMajer, the commands you suggested do not solve @mwilck's usecase. If there is a conflict, the changes from the other branch win as expected.

@mwilck you can always report the change with a later commit.

@hramrach
Copy link
Contributor

What are the 'wrong incentives' you envision here? It's not clear to me.

@mwilck
Copy link
Contributor

mwilck commented Feb 25, 2026

Force-merging blindly. Force-forwarding from Factory to somewhere else without taking a closer look.

@hramrach
Copy link
Contributor

I can't say about other users.

My use case is that I forward simple packages I maintain to different OS releases. I do not look at them because I know I do not have separate content for different releases, the package should be the same everywhere where it's maintained.

The other use case is forwarding a version of a package I have already built and tested for the release in question. I have already looked at it at that point.

@hramrach
Copy link
Contributor

And I don't want some merge artifact in either of these cases, I want exactly the content I am forwarding..

@dmach
Copy link
Contributor

dmach commented Feb 26, 2026

I was checking how the individual scenarios work with real-life data and ended up with a script I'm pasting here for reference: (the script is for development purposes and better understanding how the underlying git commands work, it's not supposed to replace this PR)

#!/bin/sh


git-obs -G obs repo clone pool/bash -b factory --directory=bash-factory
git-obs -G obs repo clone pool/bash -b slfo-main --directory=bash-slfo-main


# This synchronizes the contents of the branches, we only need to create a new commit.
# We probably want this in the "sync mode" when we don't care about any git history.
# It is closest to the original `osc sr` behavior.
cp -a bash-slfo-main bash-slfo-main-read-tree-factory
pushd bash-slfo-main-read-tree-factory
    git read-tree -u --reset origin/factory
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum
popd



# -X ours produces broken repo (basically a random mix of old and new files)
# -> unusable
cp -a bash-slfo-main bash-slfo-main-merge-ours-factory
pushd bash-slfo-main-merge-ours-factory
    git merge -s recursive -X ours origin/factory --allow-unrelated-histories
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum
popd


# -X theirs works relatively nicely, but leaves extra files
# -> unusable
cp -a bash-slfo-main bash-slfo-main-merge-theirs-factory
pushd bash-slfo-main-merge-theirs-factory
    git merge -s recursive -X theirs origin/factory --allow-unrelated-histories
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum
popd


# -X theirs + read-tree synchronizes the contents while adding git history from the source repo through the merge commit
# It does what 'osc sr` did + there's the git history on top
cp -a bash-slfo-main bash-slfo-main-merge-ours-factory-read-tree-factory
pushd bash-slfo-main-merge-ours-factory-read-tree-factory
    git merge -s recursive -X ours origin/factory [--allow-unrelated-histories]
    git read-tree -u --reset origin/factory
    git commit --amend
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum

    echo -n "Number of different commits between origin/factory origin/slfo-main: "
    git rev-list origin/factory origin/slfo-main | wc -l
popd


pushd bash-factory
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum
popd


pushd bash-slfo-main
    sha256sum `ls | grep -v sha256sum | sort` > sha256sum
popd

Considerations:

  • shouldn't we extend the commit message with source remote url, branch and commit? it would be nice for tracking, especially for read-tree without merge, where we don't pull any new history entries in.
  • the operations are not thread-safe; always working in a temp directory could fix that; or mitigate by resolving the source ref first and using it in all consequent commands; it's nothing urgent, people usually don't trigger multiple commands on the same repo in parallel...
  • we need to make sure we're not forcibly resetting contents of the checkout, people may have modified files that shouldn't be overwritten
  • the current implementation doesn't handle fast-forwards well (leading to empty commit -> abort)

@hramrach
Copy link
Contributor

For git workflow we want to default to merging the upstream. That is for submit from Factory to Leap 16.0 either the Leap 16 branch can be fast-forwarded to Factory or a merge commit should be created.

So the first thing would be to try the FF merge.

for pool/package and its fork user/package

  • clone '''pool/package'''
  • git checkout factory
  • git checkout leap-16.0
  • try git merge --ff-only factory, it it worked skip to push
  • git merge -X theirs factory or whatever, any random strategy that always produces some merge commit
  • use whatever to align index content with factory, amend commit
  • push to a temporary branch in '''user/package'''
  • create pr from '''user/package/leap-16.0-tempbranch-vbtrgw''' to '''pool/package/leap-16.0'''

@hramrach
Copy link
Contributor

Also this might be a special case: since it's merging what is already in pool it does not need new LFS uploads, and as a result AGit might work. Reportedly the problem is writing LFS objects but for a merge inside pool no new LFS objects are needed. openSUSE/openSUSE-git#97 It would not work for submissions from develproject, though.

@AdamMajer
Copy link
Member

https://src.opensuse.org/git-workflow/autogits/pulls/131

So, keep in mind, we do not always want to merge. It's project dependent. When Leap swtiches from 16.0 to 16.1 and has some maintenacne updates, PR from factory should probably switch history to factory branch instead of merging it on top. Merging decision should be maintainer and project specific here, so ideally, not by default, and one size fits all approach.

Source remote URL is not guaranteed to stay as-is. Only in pool. But if we have it in pool, then it's already in history, which means commit message just duplicates the information for no reason.. The only reason to have a commit message like this is when reading in a tree based on another commit and not doing a merge. But keeping history is cheap, so why discard it?

@hramrach
Copy link
Contributor

Switching history is not implemented, it must be a merge with current git workflow.

@AdamMajer
Copy link
Member

Switching history is not implemented, it must be a merge with current git workflow.

Hence my linked PR, that allows such mode of operation 😉

@dmach dmach force-pushed the feature/pr_forward branch from 5fd05e4 to 02b249e Compare February 27, 2026 09:15
@dmach
Copy link
Contributor

dmach commented Feb 27, 2026

@fwag I've pushed a handful of commits on top of yours.
It works relatively nicely now (I hope), even with fast-forwardable branches.

Open questions:

  • Shouldn't we add --mode=<merge|fast-forward|sync> argument so the user explicitly selects the mode?
  • Do we want to copy all LFS objects over? It doesn't make much sense to me especially with unrelated histories. In such cases, I'm not sure if we shouldn't recommend just syncing the contents with a single commit (read-tree & commit).
  • Do we want to support merging with unrelated histories?
  • Do we want to support --source-url for arbitrary git repos? Or do we expect that users will work only with Gitea instance?
  • Are we planning to support forwarding from one OBS/Gitea instance to another?

@dmach dmach force-pushed the feature/pr_forward branch from 02b249e to 548b50f Compare February 27, 2026 09:28

# Get clone URLs
upstream_repo_obj = gitea_api.Repo.get(self.gitea_conn, upstream_owner, upstream_repo)
fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable fork_repo_obj is not used.

Copilot Autofix

AI about 15 hours ago

To fix an unused local variable, either remove the variable binding entirely (if the value is not needed) or rename it to a clearly “unused” name (if the call has important side effects but the return value is irrelevant). This avoids confusion for readers and satisfies the static analysis rule.

In this case, we should preserve the call to gitea_api.Repo.get in case it has side effects, but bind the result to a conventional unused variable name. The minimal, behavior‑preserving change is to change fork_repo_obj to _fork_repo_obj (or similar) on line 92 and leave the rest of the code untouched.

Concretely, in osc/commands_git/pr_forward.py, locate the line:

fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)

and change it to:

_fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)

No new imports, methods, or additional definitions are required.

Suggested changeset 1
osc/commands_git/pr_forward.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/osc/commands_git/pr_forward.py b/osc/commands_git/pr_forward.py
--- a/osc/commands_git/pr_forward.py
+++ b/osc/commands_git/pr_forward.py
@@ -89,7 +89,7 @@
 
         # Get clone URLs
         upstream_repo_obj = gitea_api.Repo.get(self.gitea_conn, upstream_owner, upstream_repo)
-        fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)
+        _fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)
 
         upstream_url = upstream_repo_obj.ssh_url
 
EOF
@@ -89,7 +89,7 @@

# Get clone URLs
upstream_repo_obj = gitea_api.Repo.get(self.gitea_conn, upstream_owner, upstream_repo)
fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)
_fork_repo_obj = gitea_api.Repo.get(self.gitea_conn, fork_owner, fork_repo)

upstream_url = upstream_repo_obj.ssh_url

Copilot is powered by AI and may make mistakes. Always verify output.
@hramrach
Copy link
Contributor

@fwag I've pushed a handful of commits on top of yours. It works relatively nicely now (I hope), even with fast-forwardable branches.

Open questions:

* Shouldn't we add `--mode=<merge|fast-forward|sync>` argument so the user explicitly selects the mode?

Sounds like a good idea. Autodetection is good but it may not always produce the expected result.

Note also the devel mode proposed here https://src.opensuse.org/git-workflow/autogits/pulls/131 which would require no merge, merely pushing the desired history to a branch and opening a PR. I don't know how to detect that, though. It's not merged yet which makes it impossible to test. Maybe a separate feature when it becomes available.

* Do we want to copy all LFS objects over? It doesn't make much sense to me especially with unrelated histories. In such cases, I'm not sure if we shouldn't recommend just syncing the contents with a single commit (read-tree & commit).

I think it is required to copy over all LFS objects to produce correct PR.

* Do we want to support merging with unrelated histories?

Probably yes, because bots keep creating unrelated histories for us. Maybe make it optional and not the default so that when the bots are fixed and it's not expected anymore people see it as a warning flag. ie. pass through both the --alow-unrelated-histories flag and the error when it's missing or an equivalent.

* Do we want to support `--source-url` for arbitrary git repos? Or do we expect that users will work only with Gitea instance?

I would suggest this is out of scope. Opening the PR is a gitea-specific feature and cannot be done when the source is not in gitea.

* Are we planning to support forwarding from one OBS/Gitea instance to another?

Submit form develproject to SLFO is such case.

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.

6 participants