6

I am setting up our Saleforce GIT repo and trying to plan out a solid workflow, but I'm unsure how to make it work with the Sublime Text 3: Salesforce IDE plugin (Refactored to HaoIDE) because it creates a separate (uniquely named) project folder (based on a package.xml file).

My first thought was to have to branches, one for production and one for development/sandbox, and then I would create bug and feature branches from the development branch (which represents my sandbox environment). For example:

production o-------o---------------------------------------------------o----------
                    \                                                 /
development          o-------o----------------o------------o---------o
                         \    \              /            /
new-feature               \    o--------------o----------o
                           \               /
hotfix                      o-------------o

The plugin has a settings file setup like this:

"projects":
{
    "Production":
    {
        "allowed_packages":
        [
        ],
        "default": false,
        "login_url": "https://login.salesforce.com",
        "password": "********",
        "production": "https://login.salesforce.com",
        "sandbox": "https://test.salesforce.com",
        "security_token": "Ucv1d984sdfbbg64py",
        "username": "[email protected]"
    },
    "Sandbox":  <<---- These cannot be the same, i.e. "Project-Name"
    {
        "allowed_packages":
        [
        ],
        "default": true,
        "login_url": "https://test.salesforce.com",
        "password": "********",
        "security_token": "h94jhjhyn98bvtre7wg4ewtrh",
        "username": "[email protected]"
    }
},
"workspace": "C:/projects/salesforce"

So with this setup my repo would have two separate folders. With 2 folders I can never actually merge one into the other. One additional thought I had was to make orphan branches so that each branch only has 1 folder but I'm not sure how this would look long term considering I still can't merge one branch into the other.

Note: Once the package.xml is loaded and the packaged is downloaded both the Production and Sandbox folders will have a .config folder with settings specific to the environment they're connected to which I forsee causing more issues so I plan to add .config folder to the .gitignore file

5
  • I'm not entirely sure what question you're asking, but I'm happy to help try and get you setup. We use MM/ST3 and git together with good success. MM definitely wants to create a new folder when you create a new project and it can be confusing. Commented Dec 16, 2014 at 18:42
  • Sweet! So what is your Git Flow then because at the moment with both project folders I essentially have 2 environments in one repo or branch. For example my master branch would have Production and Sandbox folders even though they both represent the same codebase, does that make sense? Commented Dec 16, 2014 at 18:53
  • 1
    In your local filesystem typically, you have one canonical set of metadata and directories. When you switch branches in git, that filesystem is overwritten and the truth resides in git.
    – greenstork
    Commented Dec 16, 2014 at 22:31
  • Is this something you can reformat into an answer or solution? I'm not sure I understand the comment here as to what I need to do for a clear functioning git flow when using this ST3: Salesforce IDE Commented Dec 16, 2014 at 23:20
  • So, I think I see what you're getting at. Here's my advice: create a MM project from the production environment, and optionally create a git repo from it. But set this aside. Treat this as a backup only. Instead, create your entire git flow around the sandbox environment. Use whatever "flow" you want and create your branches/bugfixes/etc. off of the sandbox metadata. So, in your diagram above, remove the "production" swimlane. The git repo that you really care about is the sandbox repo. Commented Dec 17, 2014 at 4:23

1 Answer 1

2

Using the comments provided I'm going to attempt to submit a response for documentation until someone else provides a better solution. Also SublimeApex has been converted to HaoIDE (the steps are basically the same)

Setting up SublimeApex HaoIDE

To start, once you install SublimeApex HaoIDE from Package Control and restart Sublime Text, you first need to setup your user settings as mentioned in the question above (this will establish your authentication to for any environment you wish to connect to)

Setup User Settings

If you switch to any of these projects then a folder with a .config folder will appear in your workspace for authentication purposes

enter image description here enter image description here

NOTE: you can create as many or as little projects from these connections as you would like. Although you can make a project for both Sandbox and Production you don't have to.

Setting up your PROJECT package

Next, simply add a new project for your sandbox environment which will fetch the environment from your active project (in this case, Sandbox)

enter image description here

This will build a default package.xml that will package your active environment into a .zip and then unpack them into the projects workspace or default workspace if there is not one declared for that project. In Sublime you should see the new folder like this.

enter image description here

Setting up your CUSTOM/REPO package

Here's the trick. If the package you pulled down is complete for your purposes then you will skip this step. For me, I want to include things like sObjects and Custom Fields so that they can be used for deployment to other environments as well. So I need to make a separate custom package for this environment, do so by either of the following:

  1. right-clicking on the sandbox folder, SublimeApex > Create Package.xml enter image description here

  2. copy the current package.xml and move to the root of your project directory (preferred)

TIP: Where ever your custom package.xml file is when you retrieve it is where the fetched package will be

Setup your custom package.xml

Since, for this example, we want sObjects and custom Fields we need to include the following:

<types>
    <members>*</members>
    <name>CustomObject</name>
</types>
<types>
    <members>*</members>
    <name>CustomField</name>
</types>

Then save right-click anywhere in the file (make sure the correct environment/project is still active), and select SublimeApex > Retrieve Package.xml

enter image description here

Once your package has been fetched you should see a new folder project-name-timestamp], for this example I gotSandbox-201412171532and within it is thesrc` file containing all the package components I want to version control in my repo

Custom Package with timestamp

NOW, that I have the src folder containing everything I want to be part of my repo I will move that folder into my Company Name folder like so:

Company Folder

Setup GIT Repository

With this src file you can now setup git init and structure your branches however you need. Most likely something as described in the question above. The repository is one thing, the environments are another. What exist in your git repository is what actually exist because it is version controlled.

You can deploy anything from within this repository using SublimeApex context menu. While in a file or by clicking any folder within the sidebar, select SublimeApex > Deploy to Server

enter image description here

Hopefully this tutorial can help you get started with managing your Salesforce repository

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .