in build_docs.pl [196:222]
sub _pick_best_remote {
#===================================
my $toplevel = shift;
return 0 unless $toplevel;
local $ENV{GIT_DIR} = dir($toplevel)->subdir('.git');
my $projectName = dir( $toplevel )->basename;
my $remotes = eval { run qw(git remote -v) } || '';
# We prefer either an elastic or elasticsearch-cn organization. All
# but two books are in elastic but elasticsearch-cn is special.
if ($remotes =~ m|\s+(\S+[/:]elastic(?:search-cn)?/$projectName)\.git|) {
# Prefer a remote with the same name as the working directory, if it exists
return $1;
}
if ($remotes =~ m|\s+(\S+[/:]elastic(?:search-cn)?/\S+)|) {
# Otherwise, take any remote from one of the preferred organizations
return $1;
}
say "Couldn't find an Elastic remote for $toplevel. Generating edit links targeting the first remote instead.";
if ($remotes =~ m|\s+(\S+[/:]\S+/\S+)|) {
return $1;
}
return 0;
}