// NewGit returns a new Git object
341460
func NewGit(username string) (*Git, error) {
	return &Git{
		host:     common.GithubOrigin,
		username: username,
	}, nil
}
1258718
func checkGitVersion(min string) error {
	want, err := version.NewVersion(min)
	if err != nil {
		return err
	}

	out, err := exec.Command("git", "version").Output()
	if err != nil {
		return err
	}

	fields := strings.Fields(string(out))
	if len(fields) < 3 {
		return fmt.Errorf("Unexpected 'git version' output: %q", string(out))
	}
	v := fields[2]
	if runtime.GOOS == "windows" && strings.Contains(v, ".windows.") {
		// on windows, git version will return for example:
		// git version 2.20.1.windows.1
		// Which does not follow the semantic versionning specs
		// https://semver.org. We remove that part in order for
		// go-version to not error.
		v = v[:strings.Index(v, ".windows.")]
	}

	have, err := version.NewVersion(v)
	if err != nil {
		return err
	}

	if have.LessThan(want) {
		return fmt.Errorf("Required git version = %s, have %s", want, have)
	}

	return nil
}
531023
func NewGitHub(ctx *context.Context) (Client, error) {
	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: ctx.Token},
	)
	httpClient := oauth2.NewClient(ctx, ts)
	base := httpClient.Transport.(*oauth2.Transport).Base
	// nolint: govet
	if &base != nil {
		base = http.DefaultTransport
	}
	// nolint: gosec
	base.(*http.Transport).TLSClientConfig = &tls.Config{
		InsecureSkipVerify: ctx.Config.GitHubURLs.SkipTLSVerify,
	}
	httpClient.Transport.(*oauth2.Transport).Base = base
	client := github.NewClient(httpClient)
	if ctx.Config.GitHubURLs.API != "" {
		api, err := url.Parse(ctx.Config.GitHubURLs.API)
		if err != nil {
			return &githubClient{}, err
		}
		upload, err := url.Parse(ctx.Config.GitHubURLs.Upload)
		if err != nil {
			return &githubClient{}, err
		}
		client.BaseURL = api
		client.UploadURL = upload
	}

	return &githubClient{client: client}, nil
}
944658
func NewAutogitManager(
	config libkbfs.Config, browserCacheSize int) *AutogitManager {
	log := config.MakeLogger("")
	browserCache, err := lru.New(browserCacheSize)
	if err != nil {
		panic(err.Error())
	}
	sharedCache, err := newLRUSharedInBrowserCache()
	if err != nil {
		panic(err.Error())
	}

	return &AutogitManager{
		config:                 config,
		log:                    log,
		deferLog:               log.CloneWithAddedDepth(1),
		registeredFBs:          make(map[data.FolderBranch]bool),
		repoNodesForWatchedIDs: make(map[libkbfs.NodeID]*repoDirNode),
		deleteCancels:          make(map[string]context.CancelFunc),
		browserCache:           browserCache,
		sharedInBrowserCache:   sharedCache,
	}
}
322838
func New(errMsg string) *Error {
	if NewLine {
		errMsg += "\n"
	}
	return &Error{message: Prefix + errMsg}
}
1048460
func (s *DescribeCodeRepositoryOutput) SetGitConfig(v *GitConfig) *DescribeCodeRepositoryOutput {
	s.GitConfig = v
	return s
}
387543
func NewIndex() (*Index, error) {
	var ptr *C.git_index

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	if err := C.git_index_new(&ptr); err < 0 {
		return nil, MakeGitError(err)
	}

	return newIndexFromC(ptr, nil), nil
}
966091
func New(token string) (*Bot, error) {
	bot := Bot{
		Token: token,
	}

	return bot.Handshake()
}
327880
func IsGitInit(ctx context.Context) bool {
	bv, ok := ctx.Value(ctxKeyGitInit).(bool)
	if !ok {
		return true
	}
	return bv
}
250976
func newLoadFromGit(c *model.CommandConfig, sp *url.URL) (err error) {
	// This method indicates we need to fetch from a repository using git
	// Execute "git clone get <pkg>"
	targetPath := filepath.Join(os.TempDir(), "revel", "skeleton")
	os.RemoveAll(targetPath)
	pathpart := strings.Split(sp.Path, ":")
	getCmd := exec.Command("git", "clone", sp.Scheme+"://"+sp.Host+pathpart[0], targetPath)
	utils.Logger.Info("Exec:", "args", getCmd.Args)
	getOutput, err := getCmd.CombinedOutput()
	if err != nil {
		utils.Logger.Fatal("Abort: could not clone the  Skeleton  source code: ","output", string(getOutput), "path", c.New.SkeletonPath)
	}
	outputPath := targetPath
	if len(pathpart) > 1 {
		outputPath = filepath.Join(targetPath, filepath.Join(strings.Split(pathpart[1], string('/'))...))
	}
	outputPath, _ = filepath.Abs(outputPath)
	if !strings.HasPrefix(outputPath, targetPath) {
		utils.Logger.Fatal("Unusual target path outside root path", "target", outputPath, "root", targetPath)
	}

	c.New.SkeletonPath = outputPath
	return
}
1019917
func New(claims map[string]interface{}) (string, error) {
	enc, err := newEncoded(claims)
	if err != nil {
		return "", err
	}

	return enc.token, nil
}
109813
func New(path string, mapping mapping.IndexMapping) (Index, error) {
	return newIndexUsing(path, mapping, Config.DefaultIndexType, Config.DefaultKVStore, nil)
}
398827
func main() {
	CheckArgs("<path>", "<revision>")

	path := os.Args[1]
	revision := os.Args[2]

	// We instantiate a new repository targeting the given path (the .git folder)
	r, err := git.PlainOpen(path)
	CheckIfError(err)

	// Resolve revision into a sha1 commit, only some revisions are resolved
	// look at the doc to get more details
	Info("git rev-parse %s", revision)

	h, err := r.ResolveRevision(plumbing.Revision(revision))

	CheckIfError(err)

	fmt.Println(h.String())
}
268408
func New(alg string, signKey interface{}, verifyKey interface{}) *JWTAuth {
	return NewWithParser(alg, &jwt.Parser{}, signKey, verifyKey)
}
620305
func (s *CodeRepositorySummary) SetGitConfig(v *GitConfig) *CodeRepositorySummary {
	s.GitConfig = v
	return s
}
214632
func main() {
	CheckArgs("<path>")
	path := os.Args[1]

	// We instance\iate a new repository targeting the given path (the .git folder)
	r, err := git.PlainOpen(path)
	CheckIfError(err)

	// Get the working directory for the repository
	w, err := r.Worktree()
	CheckIfError(err)

	// Pull the latest changes from the origin remote and merge into the current branch
	Info("git pull origin")
	err = w.Pull(&git.PullOptions{RemoteName: "origin"})
	CheckIfError(err)

	// Print the latest commit that was just pulled
	ref, err := r.Head()
	CheckIfError(err)
	commit, err := r.CommitObject(ref.Hash())
	CheckIfError(err)

	fmt.Println(commit)
}
945322
func NewMux(opts ...muxOption) *Mux {
	m := &Mux{
		p:     pat.New(),
		added: make(map[string][]patternHandler),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}