Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do you do when you find a bug in other function when develop a function?

Tags:

git

git-flow

For example, there are several big functions: User[need to develop UserControl, UserModel, UserService], and Admin, Post, Comment.

Now you are in features/post branch, developing post related functions. But you come across some bugs in User related functions.

So in terms of gitflow, what is the suggested way to do?

  1. add TODO or Fix me to User related functions, and fix the bug after finish the development of post and merged the code to master?

  2. stash the unfinished post related code, create a fix branch, fix the bug, merge to features/post, stash pop the unfinished post related code, then go on?

like image 556
Sato Avatar asked Jul 07 '16 01:07

Sato


2 Answers

You can freely fix whatever you like, whether or not it is related to the "topic" that you are working on.

Then use git commit --patch to only add commit those changes which adhere to the topic. (It is well worth learning all the details of this workflow, including how to split hunks into smaller changes, and how to edit hunks that cannot be split, yet contain a mixture of wanted and unwanted changes).

When the topic commits are all made using one or more git commit --patch operations, then all that remains in the working copy are the off-topic changes. At that point you can git checkout to a different branch to commit those, if appropriate, using git stash save and git stash pop to work around any complaints that you have unstaged changes.

If everything is in the same branch, then perhaps order doesn't matter. You can just git commit --patch the bugfix you discovered, then continue with the topic. If the fix lands in the middle of ongoing topic fixes, you can always git rebase -i: interactively rebase it so that the topic commits are together, and the incidental bugfix is before or after.

In my software organization, I'd have to create a ticket and obtain a bug number for this incidental bugfix, and submit it into Gerrit for review. If it's something obvious that looks like would get approved quickly and easily, I'd do that first, ahead of the "weighty" changes I'm working on.

like image 140
Kaz Avatar answered Oct 11 '22 04:10

Kaz


I didn't find GitFlow defines that.

For me, basing on the critical of BUG, I will decide to fix it immediately or add TODO to fix it later.

I do not fix it in the same branch with current developing feature, because it will make my teammates confused when they review my source code.

like image 27
Chung Avatar answered Oct 11 '22 05:10

Chung