-
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 StatusOwner: |
cmd/av/stack_split.go
Outdated
colors.Success(fmt.Sprintf("Successfully split the last commit into a new branch %s.\n", newBranchName)), | ||
) | ||
|
||
// List branches |
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 we don't have to show the branches.
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've removed this as per your comment
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/repository/test_repo$ git log --oneline
chafid@WINDOWS-4D6659B:
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/repository/test_repo$ echo "Third commit" > commit-3.txt
chafid@WINDOWS-4D6659B:
chafid@WINDOWS-4D6659B:/repository/test_repo$ git add commit-3.txt/repository/test_repo$ git commit -m "commit 3"
chafid@WINDOWS-4D6659B:
[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
Adding new feature to split the last commit into a new branch and revert the old branch to 1 previous commit