Jump to content

Get current branch name on command line


JanReimer

Recommended Posts

Hi,

 

I would like to know the best way to figure out on which branch a workspace is looking at. This should be done on command line.

 

My current approach is this:
- Obtain currrent changeset with cm status --xml in a powershell script which does the xml parsing

- execute "cm find changeset where changesetid=$changeset --format={branch} --nototal"

 

This has the disadvantage that the Plastic SCM server must be reachable for the cm find command. I want this to work offline.

I could run "cm ss" but I see disadvantages:

- No xml output for "cm ss" available. This makes parsing complicated.

- I don't know all valid selector formats.

- I don't know if the selector necessarily containes the branch name.

 

What is the best approach here?

 

Best regards

Jan

Link to comment
Share on other sites

Hi Carlos,

 

yes, I know. But that command does not support xml output, so parsing is difficult. I don't even know whether I can relay on the format that I see in a common scenario. What if someone has a special selector (the script is meant to run on arbitrary machines).

Could you provide xml output for "cm showselector"

 

Regards

Jan

Link to comment
Share on other sites

Hi,

 

The selector format is only dependant on if you are pointing to a branch, changeset or label. You can get the branch name as soon as you are pointing to a branch or changeset. If parsing the salector is not viable, I can check with the team if we could include a --xml option.

 

repository "gitRepo@localhost:8087"
  path "/"
    smartbranch "/main"
 
repository "gitRepo@localhost:8087"
  path "/"
    smartbranch "/main" changeset "3"
 
repository "gitRepo@localhost:8087"
  path "/"
    label "v1.0"
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...