How to deploy code/Adding a new submodule

From Wikitech

Normally, new extension submodules are added to weekly core deploy branches by the make-release release tool. This is the preferred method for deploying a new extension to production. Your extension can be added by adding it to the list in the tool's configuration file. It will begin rolling out to the WMF production wikis on the train beginning the week after it is configured.

Submodules which use a non-standard setup, such as non-conventionally named deployment branches, must be added to the core deployment branches manually.

NOTE: When adding a new extension to one branch, you also need to add the extension to any other branches in use on the cluster (typically the wmf.{N-1} branch), even if the extension will not be enabled on any wikis running that branch. Otherwise the localization cache builder will fail. It is best to add to the N-1 branch even if when is not used on the cluster anymore, to avoid catastrophic error in case of an unexpected train rollback.

$ cd mediawiki/core            # Go to your checkout of core

# Set up a local wmf/1.27.0-wmf.1 branch that tracks the remote
# You only need to do this once for each branch; if you've already got a wmf/1.27.0-wmf.1 branch, you can skip this step
# If you get an error, try 'git remote update' or 'git fetch' first
$ git checkout --track origin/wmf/1.27.0-wmf.1
Branch wmf/1.27.0-wmf.1 set up to track remote branch wmf/1.27.0-wmf.1 from origin.

# Make sure you have an up-to-date copy of the deployment branch. The submodule update might take a while.
$ git pull
$ git submodule update --init --recursive

# Add a submodule for your extension (this will check out the extension's master branch if the directory did not exist, otherwise will just use what's there)
$ git submodule add https://gerrit.wikimedia.org/r/mediawiki/extensions/MyCoolExtension.git extensions/MyCoolExtension
Cloning into extensions/MyCoolExtension...
# Check the diff. Make sure the .gitmodules entry is in line with the others (you might need to edit it and set the branch),
# and that the subproject commit hash points to the version you want deployed (which is usually the head of master)
$ git diff --cached
diff --git a/.gitmodules b/.gitmodules
index 3ab3d48..9a4cc66 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -346,3 +346,6 @@
 [submodule "extensions/PrefSwitch"]
        path = extensions/PrefSwitch
        url = https://gerrit.wikimedia.org/r/mediawiki/extensions/PrefSwitch.git
+[submodule "extensions/MyCoolExtension"]
+       path = extensions/MyCoolExtension
+       url = https://gerrit.wikimedia.org/r/mediawiki/extensions/MyCoolExtension.git
diff --git a/extensions/MyCoolExtension b/extensions/MyCoolExtension
new file mode 160000
index 0000000..46727ad
--- /dev/null
+++ b/extensions/MyCoolExtension
@@ -0,0 +1 @@
+Subproject commit 46727ad74adda33621323deb2bebdc2527cb4917

# Commit the submodule addition and submit it for review
$ git commit -a -m "Add MyCoolExtension submodule"
$ git review
# If you don't want or need this to be reviewed, you can +2 your own commit if you are in the wmf-deployment group