Git VCS - Fetching

Answered

Hi,

I build my application using rake scripts. I want to have my script to call "git rev-list --count develop" but unfortunately the branches are not known. The end goal is to have the number of commits on my current branch, assuming it's branching from develop. I would like the VCS root step to "git fetch -a origin" instead of just the branch it is about to checkout. Is that possible? Any other suggestion?

Best regards,

David

8 comments
Comment actions Permalink

Hi David,

Sorry for delay. It is not possible in TeamCity now. We have the related request https://youtrack.jetbrains.com/issue/TW-24878, please watch and vote.
As workaround you can run git fetch from the script.
Could you please provide details of your use case? Why do you need to calculate the number of commits on some branch?

0
Comment actions Permalink

From what script? I tried running it from rake but it requires authentication. I think my script should only do authentication less commands.

I use that to create version numbers, based on my branching model.

0
Comment actions Permalink

Hi,


Sorry for delay. I mean that you can run “git fetch” command from for example additional command line build step. TeamCity runs this command the same way as you run it via command line, so you need to authenticate the same way.

You can use build parameters in TeamCity to store git credentials.

0
Comment actions Permalink

What I am saying is that I do not want to store more credentials than the VCS root has already... The VCS root is responsible to get me VCS information. I don't want to replicate this everywhere! Don't you think this is quite reasonable and good practice?

0
Comment actions Permalink

Yes, you are right the solution is not good. Unfortunately there is no other workarounds at this time.

0
Comment actions Permalink

+1, I'm using few build agents, and when one of it runs build from feature branch - master is still old, so "Changes" in UI shows incorrect list of commits, as well, git merge-base HEAD origin/master consists of an another commits that has already been merged to origin/master. It is disappoints me

0

Please sign in to leave a comment.