Rename work_dir/git to work_dir/src

This is step one towards supporting GOPATH natively. With this, one can
set GOPATH={work_dir} and go will find src that we've already checked
out, and will put artifacts in a sibling dir to src that is in the
GOPATH. We'll follow this up with putting the repos into
{src_dir}/{connection}/{full_repo} - such as
"git.openstack.org/openstack-infra/zuul"

Change-Id: I5acefd212587d18d0d3cc4ccd436555734e56e63
diff --git a/tests/base.py b/tests/base.py
index 8802cfd..3ccc872 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -650,7 +650,7 @@
 
         """
         for change in changes:
-            path = os.path.join(self.jobdir.git_root, change.project)
+            path = os.path.join(self.jobdir.src_root, change.project)
             try:
                 repo = git.Repo(path)
             except NoSuchPathError as e:
@@ -1211,8 +1211,8 @@
             tmp_root = os.environ.get("ZUUL_TEST_ROOT")
         self.test_root = os.path.join(tmp_root, "zuul-test")
         self.upstream_root = os.path.join(self.test_root, "upstream")
-        self.merger_git_root = os.path.join(self.test_root, "merger-git")
-        self.launcher_git_root = os.path.join(self.test_root, "launcher-git")
+        self.merger_src_root = os.path.join(self.test_root, "merger-git")
+        self.launcher_src_root = os.path.join(self.test_root, "launcher-git")
         self.state_root = os.path.join(self.test_root, "lib")
 
         if os.path.exists(self.test_root):
@@ -1226,8 +1226,8 @@
         self.config.set('zuul', 'tenant_config',
                         os.path.join(FIXTURE_DIR,
                                      self.config.get('zuul', 'tenant_config')))
-        self.config.set('merger', 'git_dir', self.merger_git_root)
-        self.config.set('launcher', 'git_dir', self.launcher_git_root)
+        self.config.set('merger', 'git_dir', self.merger_src_root)
+        self.config.set('launcher', 'git_dir', self.launcher_src_root)
         self.config.set('zuul', 'state_dir', self.state_root)
 
         # For each project in config:
diff --git a/tests/unit/test_cloner.py b/tests/unit/test_cloner.py
index 2cdc826..02ae910 100644
--- a/tests/unit/test_cloner.py
+++ b/tests/unit/test_cloner.py
@@ -91,7 +91,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
                 cache_dir=cache_root,
             )
             cloner.execute()
@@ -149,7 +149,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
             )
             cloner.execute()
             work = self.getWorkspaceRepos(projects)
@@ -219,7 +219,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
             )
             cloner.execute()
             work = self.getWorkspaceRepos(projects)
@@ -333,7 +333,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
                 branch='stable/havana',  # Old branch for upgrade
             )
             cloner.execute()
@@ -395,7 +395,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
                 branch='master',  # New branch for upgrade
             )
             cloner.execute()
@@ -481,7 +481,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters['ZUUL_BRANCH'],
                 zuul_ref=build.parameters['ZUUL_REF'],
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
                 project_branches={'org/project4': 'master'},
             )
             cloner.execute()
@@ -546,7 +546,7 @@
                 workspace=self.workspace_root,
                 zuul_branch=build.parameters.get('ZUUL_BRANCH', None),
                 zuul_ref=build.parameters.get('ZUUL_REF', None),
-                zuul_url=self.git_root,
+                zuul_url=self.src_root,
                 branch='stable/havana',
             )
             cloner.execute()
@@ -581,7 +581,7 @@
             workspace=self.workspace_root,
             zuul_branch=None,
             zuul_ref='master',
-            zuul_url=self.git_root,
+            zuul_url=self.src_root,
             zuul_project=project,
             zuul_newrev=newRev,
         )
@@ -607,7 +607,7 @@
             workspace=self.workspace_root,
             zuul_branch=None,
             zuul_ref='master',
-            zuul_url=self.git_root,
+            zuul_url=self.src_root,
             zuul_project=project,
             zuul_newrev=newRev
         )
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 884bd9b..beddae6 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -1378,10 +1378,10 @@
         self.assertEmptyQueues()
         self.build_history = []
 
-        path = os.path.join(self.merger_git_root, "org/project")
+        path = os.path.join(self.merger_src_root, "org/project")
         if os.path.exists(path):
             repack_repo(path)
-        path = os.path.join(self.launcher_git_root, "org/project")
+        path = os.path.join(self.launcher_src_root, "org/project")
         if os.path.exists(path):
             repack_repo(path)
 
@@ -1410,10 +1410,10 @@
         A.addPatchset(large=True)
         path = os.path.join(self.upstream_root, "org/project1")
         repack_repo(path)
-        path = os.path.join(self.merger_git_root, "org/project1")
+        path = os.path.join(self.merger_src_root, "org/project1")
         if os.path.exists(path):
             repack_repo(path)
-        path = os.path.join(self.launcher_git_root, "org/project1")
+        path = os.path.join(self.launcher_src_root, "org/project1")
         if os.path.exists(path):
             repack_repo(path)
 
@@ -2733,10 +2733,10 @@
 
         # Delete org/new-project zuul repo. Should be recloned.
         p = 'org/delete-project'
-        if os.path.exists(os.path.join(self.merger_git_root, p)):
-            shutil.rmtree(os.path.join(self.merger_git_root, p))
-        if os.path.exists(os.path.join(self.launcher_git_root, p)):
-            shutil.rmtree(os.path.join(self.launcher_git_root, p))
+        if os.path.exists(os.path.join(self.merger_src_root, p)):
+            shutil.rmtree(os.path.join(self.merger_src_root, p))
+        if os.path.exists(os.path.join(self.launcher_src_root, p)):
+            shutil.rmtree(os.path.join(self.launcher_src_root, p))
 
         B = self.fake_gerrit.addFakeChange('org/delete-project', 'master', 'B')
 
@@ -3981,7 +3981,7 @@
         self.launch_server.release('.*-merge')
         self.waitUntilSettled()
 
-        path = os.path.join(self.builds[0].jobdir.git_root, "org/project1")
+        path = os.path.join(self.builds[0].jobdir.src_root, "org/project1")
         repo = git.Repo(path)
         repo_messages = [c.message.strip() for c in repo.iter_commits(ref)]
         repo_messages.reverse()
@@ -3989,7 +3989,7 @@
             'initial commit', 'add content from fixture', 'A-1']
         self.assertEqual(repo_messages, correct_messages)
 
-        path = os.path.join(self.builds[0].jobdir.git_root, "org/project2")
+        path = os.path.join(self.builds[0].jobdir.src_root, "org/project2")
         repo = git.Repo(path)
         repo_messages = [c.message.strip() for c in repo.iter_commits(ref)]
         repo_messages.reverse()
@@ -4638,7 +4638,7 @@
         build = self.builds[-1]
         ref = self.getParameter(build, 'ZUUL_REF')
 
-        path = os.path.join(build.jobdir.git_root, project)
+        path = os.path.join(build.jobdir.src_root, project)
         repo = git.Repo(path)
         repo_messages = [c.message.strip() for c in repo.iter_commits(ref)]
         repo_messages.reverse()
@@ -4709,7 +4709,7 @@
         self.assertEqual(self.getParameter(build, 'ZUUL_BRANCH'), 'mp')
         ref = self.getParameter(build, 'ZUUL_REF')
         path = os.path.join(
-            build.jobdir.git_root, 'org/project-merge-branches')
+            build.jobdir.src_root, 'org/project-merge-branches')
         repo = git.Repo(path)
 
         repo_messages = [c.message.strip() for c in repo.iter_commits(ref)]
@@ -4754,7 +4754,7 @@
         self.log.debug("Got Zuul commit for change A: %s" % commit_A)
 
         path = os.path.join(
-            job_A.jobdir.git_root, "org/project-merge-branches")
+            job_A.jobdir.src_root, "org/project-merge-branches")
         repo = git.Repo(path)
         repo_messages = [c.message.strip()
                          for c in repo.iter_commits(ref_A)]
@@ -4776,7 +4776,7 @@
         self.log.debug("Got Zuul commit for change B: %s" % commit_B)
 
         path = os.path.join(
-            job_B.jobdir.git_root, "org/project-merge-branches")
+            job_B.jobdir.src_root, "org/project-merge-branches")
         repo = git.Repo(path)
         repo_messages = [c.message.strip()
                          for c in repo.iter_commits(ref_B)]
@@ -4797,7 +4797,7 @@
         self.log.debug("Got Zuul ref for change C: %s" % ref_C)
         self.log.debug("Got Zuul commit for change C: %s" % commit_C)
         path = os.path.join(
-            job_C.jobdir.git_root, "org/project-merge-branches")
+            job_C.jobdir.src_root, "org/project-merge-branches")
         repo = git.Repo(path)
         repo_messages = [c.message.strip()
                          for c in repo.iter_commits(ref_C)]
diff --git a/zuul/launcher/server.py b/zuul/launcher/server.py
index 2827d83..575d352 100644
--- a/zuul/launcher/server.py
+++ b/zuul/launcher/server.py
@@ -94,8 +94,8 @@
         # Work
         self.work_root = os.path.join(self.root, 'work')
         os.makedirs(self.work_root)
-        self.git_root = os.path.join(self.work_root, 'git')
-        os.makedirs(self.git_root)
+        self.src_root = os.path.join(self.work_root, 'src')
+        os.makedirs(self.src_root)
         self.log_root = os.path.join(self.work_root, 'logs')
         os.makedirs(self.log_root)
         # Ansible
@@ -551,12 +551,12 @@
             repo = git.Repo.clone_from(
                 os.path.join(self.launcher_server.merge_root,
                              project['name']),
-                os.path.join(self.jobdir.git_root,
+                os.path.join(self.jobdir.src_root,
                              project['name']))
             repo.remotes.origin.config_writer.set('url', project['url'])
 
         # Get a merger in order to update the repos involved in this job.
-        merger = self.launcher_server._getMerger(self.jobdir.git_root)
+        merger = self.launcher_server._getMerger(self.jobdir.src_root)
         merge_items = [i for i in args['items'] if i.get('refspec')]
         if merge_items:
             commit = merger.mergeChanges(merge_items)  # noqa
@@ -708,7 +708,7 @@
                 if (i['connection_name'] == playbook['connection'] and
                     i['project'] == playbook['project']):
                     # We already have this repo prepared
-                    path = os.path.join(self.jobdir.git_root,
+                    path = os.path.join(self.jobdir.src_root,
                                         project.name,
                                         playbook['path'])
                     jobdir_playbook.path = self.findPlaybook(
@@ -778,7 +778,7 @@
                     # We already have this repo prepared;
                     # copy it into location.
 
-                    path = os.path.join(self.jobdir.git_root,
+                    path = os.path.join(self.jobdir.src_root,
                                         project.name)
                     link = os.path.join(root, role['name'])
                     os.symlink(path, link)
@@ -815,7 +815,7 @@
 
         with open(self.jobdir.vars, 'w') as vars_yaml:
             zuul_vars = dict(zuul=args['zuul'])
-            zuul_vars['zuul']['launcher'] = dict(git_root=self.jobdir.git_root,
+            zuul_vars['zuul']['launcher'] = dict(src_root=self.jobdir.src_root,
                                                  log_root=self.jobdir.log_root)
             vars_yaml.write(
                 yaml.safe_dump(zuul_vars, default_flow_style=False))