Skip to content
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

fix #451 #459

Merged
merged 4 commits into from
Oct 18, 2024
Merged

fix #451 #459

merged 4 commits into from
Oct 18, 2024

Conversation

hollesse
Copy link
Member

No description provided.

mob.go Outdated
@@ -551,6 +566,11 @@ func start(configuration config.Configuration) error {

createRemoteBranch(configuration, currentBaseBranch)

if !currentBaseBranch.hasLocalBranch(localBranches) {
silentgit("checkout", "-b", currentBaseBranch.Name)
silentgit("checkout", currentBranch.Name)
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this line? It feels wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @simonharrer, first I thought we need it, because the git command which is used to check if there are unpushed commits. But because of your comment I thought more about it and if there is no local base branch there can not be unpushed commits. but after implementing this change the test failed again. In the function sayLastCommitsList we look at the local basebranch. I now implemented it the way that we try this behavior if it fails we try to check against remote. Let me know if you think it is better to directly compare to the remote base branch instead of trying to compare to the local branch first. I think it could make sense but was not completely sure about it.

@@ -1001,12 +1016,16 @@ func squashOrCommit(configuration config.Configuration) string {
}
}

func sayLastCommitsList(currentBaseBranch string, currentWipBranch string) {
commitsBaseWipBranch := currentBaseBranch + ".." + currentWipBranch
Copy link
Member Author

Choose a reason for hiding this comment

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

@simonharrer this is the place where we could also just use the currentRemoteBaseBranch, this would be a much easier solution.

mob.go Outdated
@@ -122,6 +122,19 @@ func (branch Branch) hasRemoteBranch(configuration config.Configuration) bool {
return false
}

func (branch Branch) hasLocalBranch(localBranches []string) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Imo, hasLocalBranch should not need an argument localBranches. It can fetch them itself. And if local branches are fetched multiple times, I still think its worth it. When I need to find out how to check if a localBranch exists in our code, and I find this function, I don't want it to make me search for yet another function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The same is probably applicable to determineBranches

Copy link
Collaborator

@gregorriegler gregorriegler left a comment

Choose a reason for hiding this comment

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

Even better!

@hollesse hollesse merged commit ac52ce6 into main Oct 18, 2024
12 checks passed
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.

3 participants