Jump to content

Consistent way to get current branch and changeset


Stephen

Recommended Posts

I'm having a little trouble writing some automation tools to work with Plastic. It seems that every time I write a method to get the current branch and changeset for our build machine to add to the build metadata, it doesn't actually work. For example:

When explicitly up to date on a given branch, `cm status --header` will show something like this:

`/main@myworkspace@mycompany@cloud (cs:1057 - head)`

However, if I'm explicitly pointing to a specific commit, I get this:

`cs:1050@myworkspace@mycompany@cloud (head:1051)`

Which is a little frustrating because I lost the branch name, and now have to parse it differently. Fine. To get the branch, I do `cm showselector`

```

Selector for workspace myworkspace:
rep "myworkspace@mycompany@cloud"
  path "/"
    smartbranch "/main/test_versioning" changeset "1050"

```

Hey, neat, there's both of them. But, if I go back to tracking the branch instead of the specific revision, I get this:

```

Selector for workspace ramshacklers:
rep "myworkspace@mycompany@cloud"
  path "/"
    smartbranch "/main/test_versioning"

```

Well, darn, I guess I need both commands no matter what. Now, I get (to some extent) _why_ the output of these commands are different under those different circumstances. What I don't get it why the software needs to be so hostile to me getting basic information about where the repository is currently pointing? Clearly there _exists_ at any point in time a current branch, and a current revision, is there any command that can just actually consistently show me the information I need? Is there a command I just don't know about?

I acknowledge it's not hard to write a smart enough parser to wade through all this, but it has at the very least created a lot of back and forth when I thought I had solved a problem, only to discover a new layer of Plastic I hadn't considered before? I feel like I can't be the only person who is going to need to solve this problem, and the one-off nature of these kinds of scripts means I'm probably going to be re-solving it in a bunch of places since sharing quick script code like this is usually more work than it's ever worth.

 

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Hi Stephen,

I understand your frustration with this. 

The problem is that branches are an entity by themselves in Plastic, and operations can be run against them. In fact, a workspace can be pointing to an empty branch (although it will be loading the content of the parent changeset) thus the need to show in the selector the branch without the changeset. I agree that the usability here could be improved, but there is no way at the moment to get all the information with one command.

I'm sorry for the inconvenience.

 

Best,

Héber.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...