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
regards jan
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.
Regards
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Kind Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.