@@ -159,13 +159,14 @@ def button_colab(args):
159159 """Test that the URL in the Colab button matches the file path."""
160160 cell_source = args ["cell_source" ]
161161 repo = get_arg_or_fail (args ["user" ], "repo" , "<org/name>" )
162+ branch = args ["user" ].get ("branch" , "master" )
162163 docs_dir , rel_path = split_doc_path (args ["path" ])
163164
164165 # Buttons use OSS URLs.
165166 if str (docs_dir ) == "g3doc/en" :
166167 docs_dir = pathlib .Path ("site/en" )
167168
168- base_url = f"colab.research.google.com/github/{ repo } /blob/master "
169+ base_url = f"colab.research.google.com/github/{ repo } /blob/{ branch } "
169170 this_url = "https://" + str (base_url / docs_dir / rel_path )
170171
171172 if is_button_cell_re .search (cell_source ) and cell_source .find (this_url ) != - 1 :
@@ -216,13 +217,14 @@ def button_github(args):
216217 """Test that the URL in the GitHub button matches the file path."""
217218 cell_source = args ["cell_source" ]
218219 repo = get_arg_or_fail (args ["user" ], "repo" , "<org/name>" )
220+ branch = args ["user" ].get ("branch" , "master" )
219221 docs_dir , rel_path = split_doc_path (args ["path" ])
220222
221223 # Buttons use OSS URLs.
222224 if str (docs_dir ) == "g3doc/en" :
223225 docs_dir = pathlib .Path ("site/en" )
224226
225- base_url = f"github.com/{ repo } /blob/master "
227+ base_url = f"github.com/{ repo } /blob/{ branch } "
226228 this_url = "https://" + str (base_url / docs_dir / rel_path )
227229
228230 if is_button_cell_re .search (cell_source ) and cell_source .find (this_url ) != - 1 :
0 commit comments