Building Code at Logos: Third-Party Repositories

Some of our repositories reference third-party code. In many cases,
this can be managed using NuGet, but sometimes
we need to make private modifications and build from source.

We accomplish this by creating a repository for the third-party code. In some cases, this repository is added as a submodule under ext in the repositories that need it; in other cases, the binaries created from the code are committed to another repository’s lib folder. The decision depends on how complicated it is to build the code versus how useful it is for developers to have the source (and not just precompiled binaries).

In the third-party repository, the upstream branch contains the unmodified upstream code, while the master branch contains the Logos-specific modifications.

When cloning the repository locally, the origin remote refers to our repository containing the third-party code. If the original third-party code is available via git, then we add an upstream remote that references the original maintainer’s code.

Example: Creating a ThirdParty repo from source on GitHub

# clone a local copy of the remote third-party repository
gitclonehttps://github.com/user/ExampleProject.gitcdExampleProject# rename the "origin" remote (created by clone) to "upstream"
gitremoterenameoriginupstream# add Logos' repo as the "origin" remote
gitremoteaddorigingit@git:ThirdParty/ExampleProject.git# use this code as the "upstream" branch
gitcheckout-bupstreamgitpushoriginupstream# work on Logos-specific modifications
gitcheckoutmaster**makemodificationsgitcommit-am"Some important changes."# push the changes to our repo
gitpushoriginmaster

Example: Creating a ThirdParty repo from source in Subversion

# create the git repo
mkdirExampleProjectcdExampleProjectgitinit# add Logos' repo as the "origin" remote
gitremoteaddorigingit@git:ThirdParty/ExampleProject.git# seed it with the upstream code
svnexport--forcehttp://source.example.org/repos/example/tags/1.0.# add all the code
gitadd-Agitcommit-m"Add Example 1.0"# use this code as the "upstream" branch
gitcheckout-bupstreamgitpushoriginupstream# work on Logos-specific modifications
gitcheckoutmaster**makemodificationsgitcommit-am"Some important changes."# push the changes to our repo
gitpushoriginmaster

Once the repository is created, we will want to update it with new versions of the third-party code when they are released (then merge in our changes).

The new code gets committed to the upstream branch, then that gets merged into master. If necessary, conflicts are resolved, or our changes are edited/removed to reflect changes in the upstream code.

Example: Updating a ThirdParty repository from source on GitHub

# switch to the "upstream" branch, which contains the latest external code
gitcheckoutupstream# get the latest code from the "master" branch in the "upstream" repo
gitpullupstreammaster# switch to our local "master" branch, which contains Logos changes
gitcheckoutmaster# merge in the latest upstream code
gitmergeupstream**fixanyconflicts,andcommitifnecessary# push the latest merged code to our repo
gitpushoriginmaster

Example: Updating a ThirdParty repository from source in Subversion

# switch to the "upstream" branch, which contains the latest external code
gitcheckoutupstream**deleteallfilesintheworkingcopy,exceptthe'.git'directory# get the latest version of the third-party code
svnexport--forcehttp://source.example.org/repos/example/tags/1.1.# add all files in the working copy, then commit them
gitadd-Agitcommit-m"Update to Example 1.1."# switch to our local "master" branch, which contains Logos changes
gitcheckoutmaster# merge in the latest upstream code
gitmergeupstream**fixanyconflicts,andcommitifnecessary# push the latest merged code to our repo
gitpushoriginmaster