Tuesday, May 23, 2017

Configuring PowerBuilder projects to use GitHub for source control

Back in 2003, Sybase introduced CodeXchange, an online forum that allowed developers to share code samples and collaborate on open source projects.  Unfortunately, in 2009 Sybase decided to shut down that system.  The PowerBuilder code samples that had been uploaded tp CodeExchange did eventually show up again in a CodeXchange section of the PowerBuilder wiki on SAP's SCN.  Appeon also obtained permission from many of the authors to post those same PowerBuilder samples on the Code Samples section of the Appeon site.




However, the people who had collaborator projects on CodeXchange needed another option, because neither the SAP PowerBuilder wiki or the Appeon Code Samples site allowed for collaborative development.  Aware of the pending shutdown, I moved the PFC and PBNISMTP projects to Microsoft's CodePlex.

Like CodeXchange, code in CodePlex could be access from PowerBuilder through a MSSCCI to SVN proxy product.  That's because PowerBuilder uses an MSSCCI API to talk to source control systems, but both of those systems used an SVN API.  A bridge product like PushOK SVN SCC translates the MSSCCI calls to SVN calls so that the client and the source code repository can communicate.

Unfortunately, Microsoft has announced that it intends to shutdown CodePlex on December 15th, 2017,  That means those of use that moved our projects to CodePlex need to once again move them someplace else.  One potential new location is SourceForge, which also supports an SVN API.  In fact, Roy Kiesler put the PowerPrinter source code there back in 2001.

However, the site that Microsoft recommends as a replacement, and the one that has become the dominant open source hosting facility, is GitHub. The issue with moving to GitHub is that it uses a Git API rather than an SVN API, which means we need to find another proxy product to translate the MSSCCI calls to Git.

If we've been using the PushOK SVN SCC product to date to handle SVN, the first thing we might want to check out is their Git SCC product.  Unfortunately all we would find when we attempt to download the product though is a 1.0 release candidate that was published in June of 2010 and hasn't been updated since.  That's hardly reassuring.  We might also note if we went back to their SVN SCC product that the last update of that was also a release candidate for supporting SVN 1.8 published in April of 2015 and not updated since.  Subversion 1.9 was released in 2015 and the current version is 1.9.5.  It appears that PushOK has ceased development of their products sometime in the last two years.

Fortunately, there is an alternative.  A bit of searching turned up a the Git MSSCCI provider from PB Software.  It not only works, but it's free.  It's also being actively supported.  There have been releases in 2014, 2015 and 2017.

I'm going to walk through how to configure PowerBuilder to use the PB Software provider to connect PowerBuilder to GitHub.  Perhaps because of my somewhat limited experience with Git (I've used the GitHub desktop to host a JavaScript project there and the GitHub extension for Visual Studio to host a C++ project there.  Those were pretty idiot proof.  Configuring PowerBuilder to use the Git MSSCCI provider takes a bit more work.  A owe a lot of thanks to Bob Piskac of PB Software for walking me through some of the issues.

1.  Download the zip file with the provider and unzip it to your file system somewhere.  I chose to put it under the C:\Program Files(x86) directory, specifically at C:\Program Files (x86)\pbsGitMSSCCIV1build0007.

2.  Add that directory to your system path.

3.  The provider does not automatically create the registry entries needed for PowerBuilder to find it as a source control provider, despite what the readme document that comes with the download indicates.  Instead, add the following to your registry (modified as needed to match the location where you installed the provider in step 1.).  These entries are for a 64 bit machine.  If you're on a 32 bit machine still, simply remove the Wow6432Node portion of the keys.

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SourceCodeControlProvider]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SourceCodeControlProvider\InstalledSCCProviders]
"PB Native"="Software\\Sybase\\PowerBuilder\\12.6\\Native SCC"
"PBS Git MSSCCI"="Software\\PBSoftware\\PBSGitMSSCCI"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\PBSoftware]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\PBSoftware\PBSGitMSSCCI]
"SCCServerName"="PBS Git MSSCCI"
"SCCServerPath"="C:\\Program Files (x86)\\pbsGitMSSCCIV1build0007\\pbsGitMSSCCI.dll"

Bob did indicate that he was looking and creating another build that would produce those entries automatically when regsvr32 is run on the DLL.

The Git MSSCCI provider expects the PowerBuilder project to already be in a local Git repository, so we're going to create that now.

4.  Download and install TortoiseGit.  Not absolutely necessary, but I like to with with a GUI rather than the command line and TortoiseGit serves as the GUI for some of the initial work we need to do with Git.

5.  Create a GitHub account if you don't already have one.

6.  Create a new repository in Github for your project.  Leave it empty right now.

a.  Select create project from the main page.

b.  Give it a name and hit Create Repository.  Leave the checkbox to create a readme file unchecked.

c.  You should end up with a page that looks like the following.  Keep it open, as we will need the url for the project in a later step.

7.  Find the parent directory of the PowerBuilder code that you want to start hosting in GitHub, Right click on that directory and select the "Git create repository here" option.

Leave the  "Make it Bare" option unchecked and hit OK.

8.  Open the directory, right click in it and create a new text document.  Name the new text document README.md (with README in capitals).


9.  Right click on the README.md file and select Add from the TortoiseGit menu option.





10.  Right click on the file again and select "Git Commit -> "master" to commit the add to the local repository.





11.  Right click in the background of the directory and select TortoiseGit Settings.


Click OK on the dialog that appears that explains hierarchical configuration.

12.  In the settings, find Git - Remote.  Enter the URL from the project in GitHub into the URL field and hit Apply.


Click "No" when asked if you want to fetch remote branches.

Press OK on the next dialog and you should see this result.


13.  Right click in the directory background again, and this time select TortoiseGit -> Push.


That takes the files that have been committed locally and updates the remote repository with them. You will be prompted for your GitHub username and password.  You should see a summary dialog like this when you are done.


14.  The repository is now ready for you to start working with it from PowerBuilder.  Open up the IDE and the workspace in question.

15.  Open the workspace properties and select PBS Git MSSCCI from the list of source control systems.


Make sure you check the "Suppress prompts to overwrite read-only files" option and hit Apply.


16.  The output pane should indicate that the connection to source control was established.  You can now right click on the workspace and select Add to Source Control.


17.  Go back to the directory where the source code is at, right click in the directory and select TortoiseGit -> Push to send the PowerBuilder code to GitHub.  Alternatively, you can use GitHub Desktop and the Publish option as shown below.


Initially you'll need to Add the local repository to GitHub Desktop so it knows to work with it.

18.  Go back to your project in GitHub, refresh the page if necessary, and see all your code.


One thing to keep in mind is that Git is a distributed version control system.  PowerBuilder talks to your local git repository, so you can work offline.  You have to go online and do a sync with GitHub in order to post your changes and pick up changes from other users.  You'll need to use TortoiseGit, GitHub Desktop, or even the git command line to do that.

On a final note, I'm not the first person to post PowerBuilder projects to GitHub, there are already a number of existing projects there.


19 comments:

Praveen Rajarao said...

Hello Bruce,
Thanks for an in-detail explanation of how to use GIT with PB.

I just went through the entire process and it is as easy you have made it sound like. I am up and running with one of my applications on GIT. Now I will continue with the CI implementation using Jenkins.

Couple of questions:
1. How to enable 'Reserved Checkouts' using GIT? I do not want multiple developers checking out the same object on their local repos.

2. How to check-in and GIT-Push only selected objects? If I have checked in 10 objects, and I want to push only 5 out of them to the server, how can I do that?

Thanks and keep doing the awesome job as always. I plan to write my version of the migration to GIT on my website - www.pbgeeks.com. Do take a look when you get a chance.

Thanks
Praveen.
www.pbgeeks.com

Praveen Rajarao said...

Hello Bruce,

I appreciate you taking some time to reply to my question above in the Appeon community here - https://community.appeon.com/groups/powerbuilder/powerbuilder-and-github-questions.

I just wanted to paste the link on this article so your readers can refer if required.

Thanks once again
Praveen
www.pbgeeks.com

chirino said...

Hi Bruce,
Thanks very much for this explanation, I was able to setup my PB project but I have few questions

1 - when setting source control in workspace properties, do we need to add User ID and Project path?

2 - I could check out and check in objects however I could not not see the changes in the repository; after check in what else do I need to do?

3 - Show Differences, Show History is not working anymore

One more time, thanks very much for your help.

Best regards
Enrique

Bruce Armstrong said...

It appears that the provider of the MSSCCI to Git bridge has not implemented a number of the options in the PB IDE (i.e., history). You would need to use standard Git tools in the Git repository to view that information.

Unknown said...

Hi Bruce,

I tried adding PB code using attached mentioned steps but it did not work for me.
I m getting
Unable to Load SCC Provider DLL: C:\\Program Files (x86)\\pbsGitMSSCCIV1build0007\\pbsGitMSSCCI.dll
Restoring SCC Offline Status Cache from last backup.
Unable to initialize SCC status cache from backup C:\Users\Public\Documents\Sybase\PowerBuilder 12.5\Code Examples\Benchmark\benchmark.pbc.
Initialization of PBS Git MSSCCI Failed

THe reason I could understand is because of PB Software only loaded the file pbsGitMSSCCIV1build0007.7z.
And there is not such dll I could find on mentioned path.
Can anyone please help me on this.

Bruce Armstrong said...

The .7z extension indicates it's a 7zip archive format: http://www.7-zip.org/

You need to decompress that archive to get the individual files.

Unknown said...

Hi Bruce,

I tried using above steps but it is giving me below error when I am configuring it to PB .
Nonspecific Error performing SccOpenProject.
Source control is in offline mode.
Restoring SCC Offline Status Cache from last backup.
5466 entries restored to SCC offline status cache.
Initialization of PBS Git MSSCCI Failed

I am able to perform all the steps before.

Any idea about this?

Thanks
Shaila

Bruce Armstrong said...

Check to make sure that the location you've specified in the registry entries you created match where you've actually put the extracted files from the archive.

Unknown said...

Hi Bruce,

The entry in Registry path matches the location of files from the archive.
C:\Program Files (x86)\pbsGitMSSCCIV1build0007\pbsGitMSSCCI.dll is the path mentioned in the registry and the same path I have placed the files.

I am able to configure one set of code with this method but when I am trying with the code which is not on Public Repository I am getting this.
Also we have the folder structure of the code so I have place the git2.dll on the folder where main application is.

I am wondering if it has anything to do with this.

Could you suggest? or let me know if I need to share more details with you.

Thanks ,
Shaila

Bruce Armstrong said...

>>I am able to configure one set of code with this method but when I am trying with the code which is not on
>>Public Repository I am getting this.

I'm not sure what you're referring to here.

>>Also we have the folder structure of the code so I have place the git2.dll on the folder where main application is.

The git2.dll is the compiled version of libgit2 https://libgit2.github.com/) which the plugin needs in it's directory.

Unknown said...

Hi Bruce,

>>I am able to configure one set of code with this method but when I am trying with the code which is not on
>>Public Repository I am getting this.

I'm not sure what you're referring to here.

-- The code which I am trying to convert into source control is coming from Private Git Repository. I believe this should not have any impact on PB to GIT configuration.

>>Also we have the folder structure of the code so I have place the git2.dll on the folder where main application is.

The git2.dll is the compiled version of libgit2 https://libgit2.github.com/) which the plugin needs in it's directory.

-- The directory you mean is the source code folder directory? please correct me on this.
If my source code is divided into folder structure for PBT, PBW and PBL's then where should I keep the dll (in the folder where my main application is ?).
When I am putting git2.dll on the folder where I have .Git I am getting not able to load pbsGitMSSCCI.dll. When I am putting this dll on the folder where my application PBL is I am getting:
Nonspecific Error performing SccOpenProject.
Source control is in offline mode.
Restoring SCC Offline Status Cache from last backup.
5466 entries restored to SCC offline status cache.
Initialization of PBS Git MSSCCI Failed

Bruce Armstrong said...

>>The code which I am trying to convert into source control is coming from Private Git Repository.
>>I believe this should not have any impact on PB to GIT configuration.

That's correct. The provider only works with local repositories, it knows nothing about any remote repositories.

>>The directory you mean is the source code folder directory? please correct me on this.

git2 must be in the directory where pbsGitMSSCCI.dll is at. pbsGitMSSCCI is dependant on it.

Also, make sure you have a git client available in the system path. If you open a command prompt and type git and get an error, then the plugin won't know how to find the git client.



Unknown said...

Hi Bruce,

Finally I am able to add my code to source control and not receiving the below error:
Nonspecific Error performing SccOpenProject.
Source control is in offline mode.
Restoring SCC Offline Status Cache from last backup.
5466 entries restored to SCC offline status cache.
Initialization of PBS Git MSSCCI Failed

when you are using folder structure for keeping PBL , PBT etc.
you will have to put the PBW where .git file is created I did that and it worked well.

Thanks for posting this blog and replying to queries its very helpful.

Unknown said...

Hi Bruce,
i was able to connect to repository, but when i try to add objects to source control i get the following messages
---------- Source Control
Adding selected items to source control...
Nonspecific Error Performing SccAdd()
Nonspecific Error Performing SccAdd()
Error checking in .PBG file. Verify that new entries are correct and check in .PBG file manually.
Failed to add C:\App\f_function1.srf
Failed to add C:\App\f_function2.srf
Failed to add C:\App\uo_userobject1.sru
Operation Completed
---------- Done Source Control

Could you please advice if you see this before?
Thanks in advance and sorry for my typos

YarkerZod said...

Hello Bruce, I see that your post is from 2017 I hope you can help me, I have managed to connect pb 12.6 with GIT (in my work they use this version, I doubt they can migrate to current versions), but I have a problem that has nothing to do with GIT, it happens the same with Subversion, the submenu shows the options of version control blocked, I can not do cheackout or checkin, any idea why this happens ?, maybe some configuration that I have to modify?

YarkerZod said...

Hello Bruce, I see that your post is from 2017 I hope you can help me, I have managed to connect pb 12.6 with GIT (in my work they use this version, I doubt they can migrate to current versions), but I have a problem that has nothing to do with GIT, it happens the same with Subversion, the submenu shows the options of version control blocked, I can not do cheackout or checkin, any idea why this happens ?, maybe some configuration that I have to modify?

Thanks for leaving this post, it has helped me a lot, I hope you can answer my question.

Bijal said...

Hello, That you for all the details. I was able to set it up. Can someone please let me know how to do we send up a core review request before we check in code?

Bruce Armstrong said...

Bijal,

What we used at one time was Code Collaborator (https://smartbear.com/product/collaborator/overview/). The product works great, we just stopped doing peer review on check-in, so that's why we no longer use it. It hooks in with the source control system, and supports both Git and Subversion.

Bruce Armstrong said...

YarkerZod,

i can't tell from your comment what you're using to interface PowerBuilder to SVN. Older versions of PowerBuilder (like 12.6) need a MSSCCI to SVN bridge product like AgentSVN. If you aren't using something like that, the source control system in PowerBuilder won't know how to tell the version control system that you want to lock an object for editing.