Change master->main for non bot code in repo

Bug: 183190456
Change-Id: Ia7c216db1fb9a65509305018b6c5a2a5c76c251d
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index d01ede5..439be8a 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
 
   // This field is accessed from release scripts using simple pattern matching.
   // Therefore, changing this field could break our release scripts.
-  public static final String LABEL = "master";
+  public static final String LABEL = "main";
 
   private Version() {
   }
@@ -31,7 +31,7 @@
   }
 
   static int getMajorVersion(String label) {
-    if (label.equals("master")) {
+    if (label.equals("main")) {
       return -1;
     }
     int start = 0;
@@ -49,7 +49,7 @@
   }
 
   static int getMinorVersion(String label) {
-    if (label.equals("master")) {
+    if (label.equals("main")) {
       return -1;
     }
     int start = label.indexOf('.') + 1;
@@ -67,7 +67,7 @@
   }
 
   static int getPatchVersion(String label) {
-    if (label.equals("master")) {
+    if (label.equals("main")) {
       return -1;
     }
     int skip = label.indexOf('.') + 1;
@@ -87,7 +87,7 @@
   }
 
   static String getPreReleaseString(String label) {
-    if (label.equals("master")) {
+    if (label.equals("main")) {
       return null;
     }
     int start = label.indexOf('-') + 1;
@@ -107,6 +107,6 @@
   }
 
   static boolean isDevelopmentVersion(String label, boolean isEngineering) {
-    return label.equals("master") || label.endsWith("-dev") || isEngineering;
+    return label.equals("main") || label.endsWith("-dev") || isEngineering;
   }
 }
diff --git a/src/test/java/com/android/tools/r8/ExtractMarkerTest.java b/src/test/java/com/android/tools/r8/ExtractMarkerTest.java
index 7cbcf63..6ed73d8 100644
--- a/src/test/java/com/android/tools/r8/ExtractMarkerTest.java
+++ b/src/test/java/com/android/tools/r8/ExtractMarkerTest.java
@@ -129,7 +129,7 @@
     DexString markerString =
         factory.createString(
             "~~D8{\"compilation-mode\":\"debug\",\"has-checksums\":false,"
-                + "\"min-api\":21,\"sha-1\":\"engineering\",\"version\":\"master\" }");
+                + "\"min-api\":21,\"sha-1\":\"engineering\",\"version\":\"main\" }");
     assertEquals("dex", Marker.parse(markerString).getBackend());
   }
 
@@ -139,7 +139,7 @@
     DexString markerString =
         factory.createString(
             "~~R8{\"compilation-mode\":\"release\",\"has-checksums\":true,"
-                + "\"sha-1\":\"engineering\",\"version\":\"master\" }");
+                + "\"sha-1\":\"engineering\",\"version\":\"main\" }");
     assertEquals("cf", Marker.parse(markerString).getBackend());
   }
 }
diff --git a/src/test/java/com/android/tools/r8/VersionTests.java b/src/test/java/com/android/tools/r8/VersionTests.java
index dad43b9..343ea89 100644
--- a/src/test/java/com/android/tools/r8/VersionTests.java
+++ b/src/test/java/com/android/tools/r8/VersionTests.java
@@ -33,12 +33,12 @@
     int minorVersion = Version.getMinorVersion();
     int patchVersion = Version.getPatchVersion();
     String preReleaseString = Version.getPreReleaseString();
-    if (LABEL.equals("master")) {
+    if (LABEL.equals("main")) {
       assertEquals(-1, majorVersion);
       assertEquals(-1, minorVersion);
       assertEquals(-1, patchVersion);
       assertNull(preReleaseString);
-      assertTrue(Version.getVersionString().startsWith("master"));
+      assertTrue(Version.getVersionString().startsWith("main"));
     } else {
       assertTrue(majorVersion > 0);
       assertTrue(minorVersion >= 0);
@@ -59,7 +59,7 @@
 
   @Test
   public void testDevelopmentPredicate() {
-   if (LABEL.equals("master") || LABEL.contains("-dev")) {
+    if (LABEL.equals("main") || LABEL.contains("-dev")) {
       assertTrue(Version.isDevelopmentVersion());
     } else {
       // This is a release branch, but Version.isDevelopmentVersion will still return true
@@ -70,13 +70,13 @@
 
   @Test
   public void testLabelParsing() {
-    assertEquals(-1, Version.getMajorVersion("master"));
-    assertEquals(-1, Version.getMinorVersion("master"));
-    assertEquals(-1, Version.getPatchVersion("master"));
-    assertNull(Version.getPreReleaseString("master"));
-    // 'master' is checked before 'isEngineering'.
-    assertTrue(Version.isDevelopmentVersion("master", false));
-    assertTrue(Version.isDevelopmentVersion("master", true));
+    assertEquals(-1, Version.getMajorVersion("main"));
+    assertEquals(-1, Version.getMinorVersion("main"));
+    assertEquals(-1, Version.getPatchVersion("main"));
+    assertNull(Version.getPreReleaseString("main"));
+    // 'main' is checked before 'isEngineering'.
+    assertTrue(Version.isDevelopmentVersion("main", false));
+    assertTrue(Version.isDevelopmentVersion("main", true));
 
     assertEquals(1, Version.getMajorVersion("1.2.3-dev"));
     assertEquals(2, Version.getMinorVersion("1.2.3-dev"));
diff --git a/tools/archive.py b/tools/archive.py
index e92e87d..24e8e0a 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -56,51 +56,51 @@
 def GetGitHash():
   return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
 
-def IsMaster(version):
+def IsMain(version):
   branches = subprocess.check_output(['git', 'branch', '-r', '--contains',
                                       'HEAD'])
-  # CL runs from gerrit does not have a branch, we always treat them as master
+  # CL runs from gerrit does not have a branch, we always treat them as main
   # commits to archive these to the hash based location
   if len(branches) == 0:
     return True
-  if not version == 'master':
+  if not version == 'main':
     # Sanity check, we don't want to archive on top of release builds EVER
     # Note that even though we branch, we never push the bots to build the same
-    # commit as master on a branch since we always change the version to
-    # not be just 'master' (or we crash here :-)).
-    if 'origin/master' in branches:
-      raise Exception('We are seeing origin/master in a commit that '
-                      'don\'t have \'master\' as version')
+    # commit as main on a branch since we always change the version to
+    # not be just 'main' (or we crash here :-)).
+    if 'origin/main' in branches:
+      raise Exception('We are seeing origin/main in a commit that '
+                      'don\'t have \'main\' as version')
     return False
-  if not 'origin/master' in branches:
-      raise Exception('We are not seeing origin/master '
-                      'in a commit that have \'master\' as version')
+  if not 'origin/main' in branches:
+      raise Exception('We are not seeing origin/main '
+                      'in a commit that have \'main\' as version')
   return True
 
 def GetStorageDestination(storage_prefix,
                           version_or_path,
                           file_name,
-                          is_master):
-  # We archive master commits under raw/master instead of directly under raw
+                          is_main):
+  # We archive main commits under raw/main instead of directly under raw
   version_dir = GetVersionDestination(storage_prefix,
                                       version_or_path,
-                                      is_master)
+                                      is_main)
   return '%s/%s' % (version_dir, file_name)
 
-def GetVersionDestination(storage_prefix, version_or_path, is_master):
-  archive_dir = 'raw/master' if is_master else 'raw'
+def GetVersionDestination(storage_prefix, version_or_path, is_main):
+  archive_dir = 'raw/main' if is_main else 'raw'
   return '%s%s/%s/%s' % (storage_prefix, ARCHIVE_BUCKET,
                          archive_dir, version_or_path)
 
-def GetUploadDestination(version_or_path, file_name, is_master):
-  return GetStorageDestination('gs://', version_or_path, file_name, is_master)
+def GetUploadDestination(version_or_path, file_name, is_main):
+  return GetStorageDestination('gs://', version_or_path, file_name, is_main)
 
-def GetUrl(version_or_path, file_name, is_master):
+def GetUrl(version_or_path, file_name, is_main):
   return GetStorageDestination('https://storage.googleapis.com/',
-                               version_or_path, file_name, is_master)
+                               version_or_path, file_name, is_main)
 
-def GetMavenUrl(is_master):
-  return GetVersionDestination('https://storage.googleapis.com/', '', is_master)
+def GetMavenUrl(is_main):
+  return GetVersionDestination('https://storage.googleapis.com/', '', is_main)
 
 def SetRLimitToMax():
   (soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE)
@@ -157,13 +157,13 @@
       utils.DESUGAR_CONFIGURATION_MAVEN_ZIP)
 
   version = GetVersion()
-  is_master = IsMaster(version)
-  if is_master:
-    # On master we use the git hash to archive with
-    print('On master, using git hash for archiving')
+  is_main = IsMain(version)
+  if is_main:
+    # On main we use the git hash to archive with
+    print('On main, using git hash for archiving')
     version = GetGitHash()
 
-  destination = GetVersionDestination('gs://', version, is_master)
+  destination = GetVersionDestination('gs://', version, is_main)
   if utils.cloud_storage_exists(destination) and not options.dry_run:
     raise Exception('Target archive directory %s already exists' % destination)
   with utils.TempDir() as temp:
@@ -207,7 +207,7 @@
       if file_name.endswith('.jar') and not file_name.endswith('-src.jar'):
         with zipfile.ZipFile(tagged_jar, 'a') as zip:
           zip.write(version_file, os.path.basename(version_file))
-      destination = GetUploadDestination(version, file_name, is_master)
+      destination = GetUploadDestination(version, file_name, is_main)
       print('Uploading %s to %s' % (tagged_jar, destination))
       if options.dry_run:
         if options.dry_run_output:
@@ -219,21 +219,21 @@
           print('Dry run, not actually uploading')
       else:
         utils.upload_file_to_cloud_storage(tagged_jar, destination)
-        print('File available at: %s' % GetUrl(version, file_name, is_master))
+        print('File available at: %s' % GetUrl(version, file_name, is_main))
 
       # Upload R8 to a maven compatible location.
       if file == utils.R8_JAR:
         maven_dst = GetUploadDestination(utils.get_maven_path('r8', version),
-                                         'r8-%s.jar' % version, is_master)
+                                         'r8-%s.jar' % version, is_main)
         maven_pom_dst = GetUploadDestination(
             utils.get_maven_path('r8', version),
-            'r8-%s.pom' % version, is_master)
+            'r8-%s.pom' % version, is_main)
         if options.dry_run:
           print('Dry run, not actually creating maven repo for R8')
         else:
           utils.upload_file_to_cloud_storage(tagged_jar, maven_dst)
           utils.upload_file_to_cloud_storage(default_pom_file, maven_pom_dst)
-          print('Maven repo root available at: %s' % GetMavenUrl(is_master))
+          print('Maven repo root available at: %s' % GetMavenUrl(is_main))
 
       # Upload desugar_jdk_libs configuration to a maven compatible location.
       if file == utils.DESUGAR_CONFIGURATION:
@@ -241,7 +241,7 @@
         jar_version_name = 'desugar_jdk_libs_configuration-%s.jar' % version
         maven_dst = GetUploadDestination(
             utils.get_maven_path('desugar_jdk_libs_configuration', version),
-                                 jar_version_name, is_master)
+                                 jar_version_name, is_main)
 
         with utils.TempDir() as tmp_dir:
           desugar_jdk_libs_configuration_jar = os.path.join(tmp_dir,
@@ -262,10 +262,10 @@
           else:
             utils.upload_file_to_cloud_storage(
                 desugar_jdk_libs_configuration_jar, maven_dst)
-            print('Maven repo root available at: %s' % GetMavenUrl(is_master))
+            print('Maven repo root available at: %s' % GetMavenUrl(is_main))
             # Also archive the jar as non maven destination for Google3
             jar_destination = GetUploadDestination(
-                version, jar_basename, is_master)
+                version, jar_basename, is_main)
             utils.upload_file_to_cloud_storage(
                 desugar_jdk_libs_configuration_jar, jar_destination)
 
diff --git a/tools/archive_desugar_jdk_libs.py b/tools/archive_desugar_jdk_libs.py
index 825cb91..2bc8386 100755
--- a/tools/archive_desugar_jdk_libs.py
+++ b/tools/archive_desugar_jdk_libs.py
@@ -64,7 +64,7 @@
     return version
 
 
-def Upload(options, file_name, storage_path, destination, is_master):
+def Upload(options, file_name, storage_path, destination, is_main):
   print('Uploading %s to %s' % (file_name, destination))
   if options.dry_run:
     if options.dry_run_output:
@@ -148,14 +148,14 @@
       return
 
   # Only handling versioned desugar_jdk_libs.
-  is_master = False
+  is_main = False
 
   with utils.TempDir() as checkout_dir:
     CloneDesugaredLibrary(options.github_account, checkout_dir)
     version = GetVersion(os.path.join(checkout_dir, VERSION_FILE))
 
     destination = archive.GetVersionDestination(
-        'gs://', LIBRARY_NAME + '/' + version, is_master)
+        'gs://', LIBRARY_NAME + '/' + version, is_main)
     if utils.cloud_storage_exists(destination) and not options.dry_run:
       raise Exception(
           'Target archive directory %s already exists' % destination)
@@ -165,24 +165,24 @@
     storage_path = LIBRARY_NAME + '/' + version
     # Upload the jar file with the library.
     destination = archive.GetUploadDestination(
-        storage_path, LIBRARY_NAME + '.jar', is_master)
-    Upload(options, library_jar, storage_path, destination, is_master)
+        storage_path, LIBRARY_NAME + '.jar', is_main)
+    Upload(options, library_jar, storage_path, destination, is_main)
 
     # Upload the maven zip file with the library.
     destination = archive.GetUploadDestination(
-        storage_path, LIBRARY_NAME + '.zip', is_master)
-    Upload(options, maven_zip, storage_path, destination, is_master)
+        storage_path, LIBRARY_NAME + '.zip', is_main)
+    Upload(options, maven_zip, storage_path, destination, is_main)
 
     # Upload the jar file for accessing GCS as a maven repro.
     maven_destination = archive.GetUploadDestination(
         utils.get_maven_path('desugar_jdk_libs', version),
         'desugar_jdk_libs-%s.jar' % version,
-        is_master)
+        is_main)
     if options.dry_run:
       print('Dry run, not actually creating maven repo')
     else:
       utils.upload_file_to_cloud_storage(library_jar, maven_destination)
-      print('Maven repo root available at: %s' % archive.GetMavenUrl(is_master))
+      print('Maven repo root available at: %s' % archive.GetMavenUrl(is_main))
 
 
 if __name__ == '__main__':
diff --git a/tools/compiledump.py b/tools/compiledump.py
index 3828739..bce5d75 100755
--- a/tools/compiledump.py
+++ b/tools/compiledump.py
@@ -37,10 +37,10 @@
     '--version',
     help='Compiler version to use (default read from dump version file).'
       'Valid arguments are:'
-      '  "master" to run from your own tree,'
+      '  "main" to run from your own tree,'
       '  "source" to run from build classes directly,'
       '  "X.Y.Z" to run a specific version, or'
-      '  <hash> to run that hash from master.',
+      '  <hash> to run that hash from main.',
     default=None)
   parser.add_argument(
     '--r8-jar',
@@ -236,7 +236,7 @@
   return None
 
 def download_distribution(args, version, temp):
-  if version == 'master':
+  if version == 'main':
     return utils.R8_JAR if args.nolib else utils.R8LIB_JAR
   if version == 'source':
     return '%s:%s' % (utils.BUILD_JAVA_MAIN_DIR, utils.ALL_DEPS_JAR)
@@ -340,8 +340,8 @@
       if not args.nolib and version != 'source':
         stacktrace = os.path.join(temp, 'stacktrace')
         open(stacktrace, 'w+').write(e.output.decode('UTF-8'))
-        local_map = utils.R8LIB_MAP if version == 'master' else None
-        hash_or_version = None if version == 'master' else version
+        local_map = utils.R8LIB_MAP if version == 'main' else None
+        hash_or_version = None if version == 'main' else version
         print("=" * 80)
         print(" RETRACED OUTPUT")
         print("=" * 80)
diff --git a/tools/git_sync_cl_chain.py b/tools/git_sync_cl_chain.py
index 857aab8..ea67f63 100755
--- a/tools/git_sync_cl_chain.py
+++ b/tools/git_sync_cl_chain.py
@@ -12,8 +12,8 @@
 #   * feature_final    xxxxxxxxx [feature_prereq_c: ...] ...
 #     feature_prereq_c xxxxxxxxx [feature_prereq_b: ...] ...
 #     feature_prereq_b xxxxxxxxx [feature_prereq_a: ...] ...
-#     feature_prereq_a xxxxxxxxx [master: ...] ...
-#     master           xxxxxxxxx [origin/master] ...
+#     feature_prereq_a xxxxxxxxx [main: ...] ...
+#     main             xxxxxxxxx [origin/main] ...
 #
 # Executing `git_sync_cl_chain.py -m <message>` causes the following chain of
 # commands to be executed:
@@ -54,8 +54,8 @@
                     action='store_true')
   result.add_option('--no_upload', '--no-upload',
                     help='Disable uploading to Gerrit', action='store_true')
-  result.add_option('--skip_master', '--skip-master',
-                    help='Disable syncing for master',
+  result.add_option('--skip_main', '--skip-main',
+                    help='Disable syncing for main',
                     action='store_true')
   (options, args) = result.parse_args(argv)
   options.upload = not options.no_upload
@@ -105,7 +105,7 @@
 
       pull_for_current_branch(branch, options)
 
-      if branch.name == 'master':
+      if branch.name == 'main':
         continue
 
       if status == 'closed':
@@ -119,9 +119,9 @@
       if not options.leave_upstream:
         if not has_seen_open_branch and len(closed_branches) > 0:
           print(
-              'Setting upstream for first open branch %s to master'
+              'Setting upstream for first open branch %s to main'
                   % branch.name)
-          set_upstream_for_current_branch_to_master()
+          set_upstream_for_current_branch_to_main()
 
       has_seen_open_branch = True
       has_seen_local_branch = has_seen_local_branch or (status == 'None')
@@ -170,14 +170,14 @@
   return utils.RunCmd(['git', 'cl', 'status', '--field', 'status'], quiet=True)[0].strip()
 
 def pull_for_current_branch(branch, options):
-  if branch.name == 'master' and options.skip_master:
+  if branch.name == 'main' and options.skip_main:
     return
   rebase_args = ['--rebase'] if options.rebase else []
   utils.RunCmd(['git', 'pull'] + rebase_args, quiet=True)
 
 
-def set_upstream_for_current_branch_to_master():
-  utils.RunCmd(['git', 'cl', 'upstream', 'master'], quiet=True)
+def set_upstream_for_current_branch_to_main():
+  utils.RunCmd(['git', 'cl', 'upstream', 'main'], quiet=True)
 
 # Parses a line from the output of `git branch -vv`.
 #
@@ -187,8 +187,8 @@
 #   * feature_final    xxxxxxxxx [feature_prereq_c: ...] ...
 #     feature_prereq_c xxxxxxxxx [feature_prereq_b: ...] ...
 #     feature_prereq_b xxxxxxxxx [feature_prereq_a: ...] ...
-#     feature_prereq_a xxxxxxxxx [master: ...] ...
-#     master           xxxxxxxxx [origin/master] ...
+#     feature_prereq_a xxxxxxxxx [main: ...] ...
+#     main             xxxxxxxxx [origin/main] ...
 def parse(line):
   is_current = False
   if line.startswith('*'):
diff --git a/tools/git_utils.py b/tools/git_utils.py
index 72485e1..9d9c6bd 100644
--- a/tools/git_utils.py
+++ b/tools/git_utils.py
@@ -11,8 +11,8 @@
   utils.PrintCmd(cmd)
   return subprocess.check_call(cmd)
 
-def GetHeadRevision(checkout_dir, use_master=False):
-  revision_from = 'origin/master' if use_master else 'HEAD'
+def GetHeadRevision(checkout_dir, use_main=False):
+  revision_from = 'origin/main' if use_main else 'HEAD'
   cmd = ['git', 'rev-parse', revision_from]
   utils.PrintCmd(cmd)
   with utils.ChangedWorkingDirectory(checkout_dir):
diff --git a/tools/internal_test.py b/tools/internal_test.py
index 9309237..48409c0 100755
--- a/tools/internal_test.py
+++ b/tools/internal_test.py
@@ -180,7 +180,7 @@
 def restart_if_new_version(original_content):
   new_content = get_own_file_content()
   log('Lengths %s %s' % (len(original_content), len(new_content)))
-  log('is master %s ' % utils.is_master())
+  log('is main %s ' % utils.is_main())
   # Restart if the script got updated.
   if new_content != original_content:
     log('Restarting tools/internal_test.py, content changed')
@@ -195,7 +195,7 @@
 
 def git_pull():
   ensure_git_clean()
-  subprocess.check_call(['git', 'checkout', 'master'])
+  subprocess.check_call(['git', 'checkout', 'main'])
   subprocess.check_call(['git', 'pull'])
   return utils.get_HEAD_sha1()
 
diff --git a/tools/r8_release.py b/tools/r8_release.py
index 72a5e02..397c97d 100755
--- a/tools/r8_release.py
+++ b/tools/r8_release.py
@@ -68,13 +68,13 @@
         old_version = '%s.%s-dev' % (R8_DEV_BRANCH, patch_version)
         version = '%s.%s-dev' % (R8_DEV_BRANCH, patch_version + 1)
 
-        # Verify that the merge point from master is not empty.
+        # Verify that the merge point from main is not empty.
         merge_diff_output = subprocess.check_output([
           'git', 'diff', 'HEAD..%s' % commithash]).decode('utf-8')
         other_diff = version_change_diff(
-            merge_diff_output, old_version, "master")
+            merge_diff_output, old_version, "main")
         if not other_diff:
-          print('Merge point from master (%s)' % commithash, \
+          print('Merge point from main (%s)' % commithash, \
             'is the same as exiting release (%s).' % old_version)
           sys.exit(1)
 
@@ -83,7 +83,7 @@
             subprocess.check_call([
                 'git', 'cherry-pick', '--no-edit', pre_commit])
 
-        # Merge the desired commit from master on to the branch.
+        # Merge the desired commit from main on to the branch.
         subprocess.check_call([
           'git', 'merge', '--no-ff', '--no-edit', commithash])
 
@@ -96,7 +96,7 @@
         version_diff_output = subprocess.check_output([
           'git', 'diff', '%s..HEAD' % commithash]).decode('utf-8')
 
-        validate_version_change_diff(version_diff_output, "master", version)
+        validate_version_change_diff(version_diff_output, "main", version)
 
         # Double check that we want to push the release.
         if not args.dry_run:
@@ -488,7 +488,7 @@
       with utils.ChangedWorkingDirectory(temp):
         library_gfile = ('/bigstore/r8-releases/raw/%s/%s/%s'
               % (DESUGAR_JDK_LIBS, library_version, library_archive))
-        configuration_gfile = ('/bigstore/r8-releases/raw/master/%s/%s'
+        configuration_gfile = ('/bigstore/r8-releases/raw/main/%s/%s'
               % (configuration_version, configuration_archive))
 
         download_gfile(library_gfile, library_archive)
@@ -685,7 +685,7 @@
         subprocess.check_call(['git', 'checkout', branch_version])
 
         # Rewrite the version, commit and validate.
-        old_version = 'master'
+        old_version = 'main'
         full_version = branch_version + '.0-dev'
         version_prefix = 'LABEL = "'
         sed(version_prefix + old_version,
@@ -754,7 +754,7 @@
   result = argparse.ArgumentParser(description='Release r8')
   group = result.add_mutually_exclusive_group()
   group.add_argument('--dev-release',
-                      metavar=('<master hash>'),
+                      metavar=('<main hash>'),
                       help='The hash to use for the new dev version of R8')
   group.add_argument('--version',
                       metavar=('<version>'),
@@ -769,10 +769,10 @@
                       help='Update studio mirror of com.android.tools:desugar_jdk_libs')
   group.add_argument('--new-dev-branch',
                       nargs=2,
-                      metavar=('<version>', '<master hash>'),
+                      metavar=('<version>', '<main hash>'),
                       help='Create a new branch starting a version line (e.g. 2.0)')
   result.add_argument('--dev-pre-cherry-pick',
-                      metavar=('<master hash(s)>'),
+                      metavar=('<main hash(s)>'),
                       default=[],
                       action='append',
                       help='List of commits to cherry pick before doing full '
diff --git a/tools/run_on_app_dump.py b/tools/run_on_app_dump.py
index cc22a3b..779af1d 100755
--- a/tools/run_on_app_dump.py
+++ b/tools/run_on_app_dump.py
@@ -474,7 +474,7 @@
 
 
 def version_is_built_jar(version):
-  return version != 'master' and version != 'source'
+  return version != 'main' and version != 'source'
 
 
 def compute_size_of_dex_files_in_package(path):
@@ -931,7 +931,7 @@
                     help='The shrinkers to use (by default, all are run)',
                     action='append')
   result.add_option('--version',
-                    default='master',
+                    default='main',
                     help='The version of R8 to use (e.g., 1.4.51)')
   (options, args) = result.parse_args(argv)
 
@@ -1083,7 +1083,7 @@
         as_utils.MoveFile(
           os.path.join(temp_dir, target), os.path.join(temp_dir, 'r8lib.jar'),
           quiet=options.quiet)
-    elif options.version == 'master':
+    elif options.version == 'main':
       if not (options.no_build or options.golem):
         gradle.RunGradle(['r8', '-Pno_internal'])
         build_r8lib = False
diff --git a/tools/trigger.py b/tools/trigger.py
index 482608a..984cc08 100755
--- a/tools/trigger.py
+++ b/tools/trigger.py
@@ -42,7 +42,7 @@
 def get_builders():
 
   is_release = False
-  master_builders = []
+  main_builders = []
   release_builders = []
   with open(LUCI_SCHEDULE, 'r') as fp:
     lines = fp.readlines()
@@ -57,13 +57,13 @@
           release_builders.append(builder)
         else:
           assert 'release' not in builder
-          master_builders.append(builder)
-  assert DESUGAR_BOT in master_builders
+          main_builders.append(builder)
+  assert DESUGAR_BOT in main_builders
   print 'Desugar builder:\n  ' + DESUGAR_BOT
-  master_builders.remove(DESUGAR_BOT)
-  print 'Master builders:\n  ' + '\n  '.join(master_builders)
+  main_builders.remove(DESUGAR_BOT)
+  print 'Main builders:\n  ' + '\n  '.join(main_builders)
   print 'Release builders:\n  ' + '\n  '.join(release_builders)
-  return (master_builders, release_builders)
+  return (main_builders, release_builders)
 
 def sanity_check_url(url):
   a = urllib.urlopen(url)
@@ -97,15 +97,15 @@
     return 1
 
   commit = None if (options.cl or options.desugar)  else args[0]
-  (master_builders, release_builders) = get_builders()
-  builders = release_builders if options.release else master_builders
+  (main_builders, release_builders) = get_builders()
+  builders = release_builders if options.release else main_builders
   if options.builder:
     builder = options.builder
-    assert builder in master_builders or builder in release_builders
+    assert builder in main_builders or builder in release_builders
     builders = [options.builder]
   if options.desugar:
     builders = [DESUGAR_BOT]
-    commit = git_utils.GetHeadRevision(utils.REPO_ROOT, use_master=True)
+    commit = git_utils.GetHeadRevision(utils.REPO_ROOT, use_main=True)
   if options.cl:
     trigger_cl(builders, options.cl)
   else:
diff --git a/tools/utils.py b/tools/utils.py
index da4a0e4..5c1b32b 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -263,10 +263,10 @@
       sha1.update(chunk)
   return sha1.hexdigest()
 
-def is_master():
+def is_main():
   remotes = subprocess.check_output(['git', 'branch', '-r', '--contains',
                                      'HEAD'])
-  return 'origin/master' in remotes
+  return 'origin/main' in remotes
 
 def get_HEAD_sha1():
   return get_HEAD_sha1_for_checkout(REPO_ROOT)