func (svc *Service) getSourcegraphVersion(ctx context.Context) (string, error) {
	var result struct {
		Site struct {
			ProductVersion string
		}
	}
	ok, err := svc.client.NewQuery(sourcegraphVersionQuery).Do(ctx, &result)
	if err != nil || !ok {
		return "", err
	}
	return result.Site.ProductVersion, err
}
getSourcegraphVersion queries the Sourcegraph GraphQL API to get the
current version of the Sourcegraph instance.
package service
import (
	"context"
	"encoding/json"
	"fmt"
	"html/template"
	"os"
	"os/exec"
	"path"
	"regexp"
	"strings"
	"github.com/cockroachdb/errors"
	batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
	"github.com/sourcegraph/src-cli/internal/api"
	"github.com/sourcegraph/src-cli/internal/batches"
	"github.com/sourcegraph/src-cli/internal/batches/docker"
	"github.com/sourcegraph/src-cli/internal/batches/executor"
	"github.com/sourcegraph/src-cli/internal/batches/graphql"
)
type Service struct {
	allowUnsupported bool
	allowIgnored     bool
	allowFiles       bool
	client           api.Client
	features         batches.FeatureFlags
	imageCache       *docker.ImageCache
}
type Opts struct {
	AllowUnsupported bool
	AllowIgnored     bool
	AllowFiles       bool
	Client           api.Client
}
var (
	ErrMalformedOnQueryOrRepository = errors.New("malformed 'on' field; missing either a repository name or a query")
)
func New(opts *Opts) *Service {
	return &Service{
		allowUnsupported: opts.AllowUnsupported,
		allowIgnored:     opts.AllowIgnored,
		allowFiles:       opts.AllowFiles,
		client:           opts.Client,
		imageCache:       docker.NewImageCache(),
	}
}
const sourcegraphVersionQuery = `query SourcegraphVersion {
	site {
	  productVersion
	}
  }
  `