How do I check the contents of a file as part of a merge check or pre hook in Bitbucket? - bitbucket

As part of a Bitbucket pull-request, I would like to create a merge check (or maybe pre-hook) on the master branch of some of my repos to ensure that the pubspec.yaml files, which have multiple ref: develop lines to be switched back to ref: master when merging back into master. On all other branches I would like it to remain as ref: develop so the merge check or pre hook shouldn't trigger on any of those branches until it's being merged into master.
Any help on this would be appreciated.

Related

How to update my working Git branch from another branch (develop) ? using github Desktop App

Wanna know how to update feature branch with respect to base branch (i.e. development)
I don't wanna use commands; so that's why I prefer Github Desktop
Suppose I have the following branches
master
development
API-Integration
Now I have finished my changes on the API-Integration branch and if someone committed changes on the development branch, then how can I update my feature branch (API-Integration) ;
We can use the below steps. Adding the link with screenshot as well for your reference.
In GitHub Desktop, click Current Branch.
Click Choose a branch to merge into BRANCH.
Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH.
Github desktop merge branches

Merging master branch to current before building

I need to merge my master branch code to current branch before building. We don't have access to Git Publisher. I wanted to know what my options are.
I looked into an advanced feature to "Merge before Build" but that seems to merge current branch to master?
Thanks for your help!

jenkins build with bitbucket

I Have been working on bitbucket and jenkins for android applications. I am having many branches in my repository and i want to track just my master branch in jenkins where it meets the following criteria. 1) When we push any code with name 'A' into master it should automatically trigger a build.2) when we push a code as name 'B' into the same master branch it shouldn't trigger the build. Is there a way to do it. I tried excluding branch by using :^(?!.release).*$ but it is picking all other branches too.
Can anyone help?
You can specify which branch to be built in your job like this:
If you don't want the build to occur for specific codes then you can add them in to the Excluded Regions
Go to Additional Behaviors under Git in your job configuration and select Polling ignores commits in certain pathsand add the paths to the files for those you want to ignore builds if any changes happen to them:
This should work!

Not able to see from where the branch was created from

I am using bitbucket. I create a branch from another branch. But no where i can see this hierarchy as to from where this new branch was created from. Is there a way to make this hierarchy.
use
git merge-base master your-branch
to find the best common ancestor between two branches (usually the branching point).
otherwise you can use this command
git reflog show --no-abbrev your-branch
It will output all changes made to the branch, including it's creation, for example (I created branch xxx from master branch):

Can an old branch be remerged?

I finished working on a local branch1 and merged it to master.
Now I would like to work on another feature for my application and so I will create a second local branch2, finish to add the feature and merge to master also branch2. This can go on for as long as I need to implement my application with features and until my application is completed.
Suppose now that after all these implementations I would like to make some improvement or change on the topic that was the job of branch1, say the static pages about, help and contact. Is it possible to checkout to and reuse branch1 for these changes or that branch cannot be used anymore and should rather be deleated?
After a while there might be a considerable pileup of old topic branches that I initially may have wanted to keep for these purposes. However these old branches are all outdated, no more a complete reproduction of the master branch as they were when created: is this a prerequisite in order to merge with success?
The branching/merging strategy is yours to decide but you seem to describe a feature-based workflow.
In that case, after you have merged your feature branch branch1 to master, the content/history of this feature is contained in the master branch thanks to the merge. branch1 becomes useless and even obsolete with time so you can safely remove it so that old feature branches don't accumulate in your repository.
If you then look at the improvements you want to add to the functionality introduced by branch1, you can see those improvements as a new feature and therefore create a new feature branch from master to perform those improvements.
How you should organize your workflow is rather subjective and the best strategy often depends on how the project is organized in terms on contributors and how you deploy your changes.
You can use these old branches, but ... you should merge new changes from master before (So you can avoid big merging problems in future). When you need to reincarnate old branch do:
git checkout very-old-branch
git pull ./ master
# do some changes into very-old-branch
git add .
git commit -m 'changes in the very old branch'
# need to merge very old branch with new changes into master again
git checkout master
git pull ./ very-old-branch
git push origin master
But it would be better not to be necromancer and to just create new branch and make changes in it:)
You should take a look on gitflow.
Its a very known workflow for doing such kind of development as you are asking
The full workflow will look like this. In your case you refer to the feature branches (purple ones).
The relevant article is here:
http://nvie.com/posts/a-successful-git-branching-model/
As you can see you keep working on new features all the time and once you done with them you simply merge them back to dev (in your case can be master)

Resources