Hi i'm fairly new at git and bitbucket, and i've tired to find a way to format code before it's beeing merged with origin.
the issue i'm trying to solve is that we constantly get merge conflicts, that aren't real conflict, due to developers using their ovn code formatting templates.
i've tried to find examples through google and forums that either solve my issue or point me in the right direction but with no luck.
could i use hooks or something similar to format the code before merge? or should the problem be solved elsewhere
Hi Jan Bom Trap and Welcome,
IMHO this should be fixed on the developer IDE side, not sure what are you using so the proposed solution might or not be implemented depending of the IDE features.
My team are used to code using Eclipse IDE, all of us use a prefefined Code Formatting Template and also we have configure the IDE to auto-formatting the code when saved the file.
On Eclipse IDE see:
In this way, only changes in the code are reflected in Pull Request.
Hope this helps.
thanks for your respons. we primarily use toad for oracle as an IDE, manily oracle database programming and oracle forms.
we've discussed if its possible to auto format all code(or files with specific extensions) prior to merge via a hook in bitbucket. if it is possible, then we wouldn't have to ensure that all developers use the exact same formatting profile. bitbucket would enforce the company profile on all code prior to merge. the developers could then use whatever profile they prefer locally.
but as far as i can understand from your answer, it's not the "usual way" that this is done?
At least from my experience, the team should adhere to the same Code Style to avoid this kind of problem.
Apart from that, while developing a Java code, we also use some maven plugins to force that code is correctly formatted and report the problems found.
See Apache Maven Checkstyle Plugin for further information, not idea if you can use something similar with Oracle "code"
You are welcome :)
Did my answer solves your problem?
If so, consider to mark the proposed solution as an 'Accepted answer'. This will help other people with the same or a quite similar problem to find a solution in a easy and faster way.
In addition, by doing this the post will automatically gain the "Solved:" prefix in search results to indicate other people that no further support is needed.
Similar question... our build fails when code is wrongly formatted.
It seems like putting the cart in front of the horse: formatting can be automated. why not format automatically? Instead of asking every developer to do it, do it in one place.
checkin should be able to reformat code. it should be possible to include/exclude because some code should be excluded--examples are generated code.
Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events