Multi platform Git descriptor paths

Hey Philip, Is there any progress on making the git descriptor multi-platform? Currently, if I wanted to point to a local repo (thus avoiding credential issues), I can only point to a single path, not a win_path, mac_path, linux_path as you can with dev descriptors.
It would be really handy to be able to point to a local repo and pick a branch in the descriptor without having to set up credentials for accessing private remote repos.

1 Like

Hey Patrick, seems like a reasonable suggestion.
I can see you’ve asked about this previously, so I’ll check in with the team to see what their thoughts are. I think this will probably need to be a feature request.

I’d have to test, but I wonder if you could work around it in the meantime by modifying the bootstrap hook, and handling the os specific paths there. I’ll see if I can mock up a test.

1 Like

Hey @Patrick
I had a play with the hook and I think you can achieve what you’re after. I’ve attached the python script. Unfortunately, I can’t seem to upload the script as a python file this something we’ll need to look into, so here it is in message:

from sgtk import get_hook_baseclass

class Bootstrap(get_hook_baseclass()):

    def init(self, shotgun, pipeline_configuration_id, configuration_descriptor, **kwargs):
        self.shotgun = shotgun
        self.pipeline_configuration_id = pipeline_configuration_id
        self.configuration_descriptor = configuration_descriptor

    def can_cache_bundle(self, descriptor):
        # check for git_branch descriptors and return true if found so that we can handle the downloading
        descriptor_data = descriptor.get_dict()
        if descriptor_data and descriptor_data["type"] == "git_branch":
            self.logger.info("found a git_branch descriptor")
            return True

        return False

    def populate_bundle_cache_entry(self, destination, descriptor, **kwargs):
        # Get the "path" provided in the descriptor
        source_path = descriptor.get_dict()["path"]
        # now adjust the path to suit the OS
        new_source_path = source_path.replace("/Users/bad_path/source_code/","/Users/philips1/")
        self.logger.info("New source path %s" % new_source_path)

        # Now update the descriptor source path
        # It's a bit hacky but it saves us having to implement the whole git branch checkout behaviour
        descriptor._io_descriptor._path = new_source_path

        # Now let it perform the default behaviour
        descriptor.ensure_local()

You could actually add the Windows, Mac, and Linux paths to the descriptor in your env yml, and then you could extract the correct path from the dictionary returned by descriptor.get_dict(). However, it will some what silently throw a warning in the logs that there are parameters that will be ignored.

apps.tk-multi-breakdown.location:
  type: git_branch
  path: "/Users/bad_path/source_code/tk-multi-breakdown"
  branch: master
  version: e2960cb
  windows_path: "/windows/path/to/bundle/tk-multi-breakdown"
  mac_path: "/mac/path/to/bundle/tk-multi-breakdown"
  linux_path: "/linux/path/to/bundle/tk-multi-breakdown"
2 Likes

Hi Patrick

Just to let you know, I’ve spoken to the team, and we have logged the request for this feature, though I have no eta currently on when we might implement it.

Thanks
Phil

1 Like