how to get git remote push branch name dynamically in script/Travis?

100 Views Asked by At

I am having a shell script basically whenever a user is making any changes in git file travis will start running and in Travis YAML file I have specified shell script path and shell script basically compare my current_working_branch with remote push branch.

I am using the below command to get the change file and running Pylint on the changed file.

all_changed_files=$(git diff-tree --name-only -r --no-commit-id --line-prefix=$(git rev-parse --show-toplevel)/ $TRAVIS_BRANCH origin/main | grep '\.py'$)

So in the above command origin/main is fixed and working fine I am getting problems when I am trying to push changes from $TRAVIS_BRANCH (current local branch) to a new branch let us say origin/ABC (git push -u origin ABC)

So is there any way to get the details of what branch a user is pushing so that I will use it in my script file. (I have checked the Travis CI document but no luck)?

0

There are 0 best solutions below