-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add av stack split <new branch> to split last commit into a new branch #472
base: master
Are you sure you want to change the base?
Conversation
Current Aviator status
This pull request is currently open (not queued). How to mergeTo merge this PR, comment
See the real-time status of this PR on the
Aviator webapp.
Use the Aviator Chrome Extension
to see the status of your PR within GitHub.
|
🔃 FlexReview StatusWarning
This might slow down the review process. If possible, split the PR into smaller ones Owner: |
There's another big change going on. Let me hold this until it's merged. |
Noted @draftcode , thanks for the update |
Some more items:
|
- switch to new branch if split successful
hi @draftcode @tulioz I've updated the PR as per your comments. But I think there's a conflict because of the other branch that got committed in the PR. Should I fix the conflict or you guys should do it? |
cmd/av/av
Outdated
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.
Looks like the binary is still part of the PR, you may have to do some squashing to get rid of it
@Chafid thanks for adding support for no branch name submitted, it looks really good! To answer your question from this weekend, if you could rebase and migrate the command to Three requests still:
|
Hi @tulioz , I migrated the split command to branch, and I added av adopt command once the split is finished. |
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 joining everything under the av branch
command, and addressing the other feedback. Left one comment for code change, and then this following scenario still seems to not work as I'd expect.
av branch commit-1
echo "First commit" > commit-1.txt
git add commit-1.txt
git commit -m "commit 1"
echo "Second commit" > commit-2.txt
git add commit-2.txt
git commit -m "commit 2"
av branch --split
av switch commit-1
echo "Third commit" > commit-3.txt
git add commit-3.txt
git commit -m "commit 3"
av branch --split
av tree
Looks like we still get into a split state when we'd expect that on trying to split commit 3 we'd get an error since the branch commit-1 is not the tip any more
cmd/av/branch.go
Outdated
) | ||
|
||
// Adopt new branch to av database | ||
err = adoptCmd.RunE(nil, []string{"parent", currentBranchName}) |
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.
We can call adoptForceAdoption(repo, db, newBranch, oldBranch)
directly
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.
Hi @tulioz , I update to use adoptForceAdoption
for updating the av database.
Also, maybe I misunderstand what you mean by "tip of the branch". I assumed that the branch needs to be on its last commit for this split command to run. Is this correct? Because if that's correct then this should work as expected.
When you switch to another branch then the user automatically is on the last commit of that branch, so the split should work.
But if you switch to another commit, like this:
chafid@WINDOWS-4D6659B:~/repository/test_repo$ av switch commit-2
chafid@WINDOWS-4D6659B:~/repository/test_repo$ git log --oneline
ccf90a5 (HEAD -> commit-2) commit 2
6714a51 (commit-1) commit 1
0e32223 (origin/main, origin/HEAD, main) 1st commit
chafid@WINDOWS-4D6659B:~/repository/test_repo$ av switch 6714a51
chafid@WINDOWS-4D6659B:~/repository/test_repo$ echo "Third commit" > commit-3.txt
chafid@WINDOWS-4D6659B:~/repository/test_repo$ git add commit-3.txt
chafid@WINDOWS-4D6659B:~/repository/test_repo$ git commit -m "commit 3"
[detached HEAD e17cd79] commit 3
1 file changed, 1 insertion(+)
create mode 100644 commit-3.txt
chafid@WINDOWS-4D6659B:~/repository/test_repo$ av branch --split
The split operation was aborted.
The original branch remains intact.
This should work as expected
add condition to check detached head
@Chafid sorry for the delay in my response, been a hectic week for me. You are correct we want to force tip of branch, but I think we should also enforce tip of stack. Today if a stack looks like this:
and someone runs the command on first branch they'll end up with
and now they have a fork to resolve, ideally we'd only want to let them run on the tip of second_branch so that their stack can only end up like this
Let me know what you think! |
Ah got it @tulioz . Is there already a mechanism in av to check whether the user is already on the tip stack? Or I need to figure it out myself? |
Hi @tulioz , I've added the check to only split when in tip of the stack. Please check it |
Hey @Chafid, there should be code in
|
Hi @tulioz , are you sure you have the latest update? It works correctly on my local
|
Adding new feature to split the last commit into a new branch and revert the old branch to 1 previous commit