func usesGit(ctx context.Context, charmPath string, cancelFunc func()) bool {
	defer cancelFunc()
	if _, err := os.Stat(filepath.Join(charmPath, ".git")); err == nil {
		return true
	}
	args := []string{"rev-parse", "--is-inside-work-tree"}
	execCmd := exec.CommandContext(ctx, "git", args...)
	execCmd.Dir = charmPath

	_, err := execCmd.Output()

	if ctx.Err() == context.DeadlineExceeded {
		logger.Debugf("git command timed out for charm in path: %q", charmPath)
		return false
	}

	if err == nil {
		return true
	}
	return false
}
// usesGit first check checks for the easy case of the current charmdir has a
// git folder.
// There can be cases when the charmdir actually uses git and is just a subdir,
// hence the below check
usesGit first check checks for the easy case of the current charmdir has a
git folder.
There can be cases when the charmdir actually uses git and is just a subdir,
hence the below check
// usesGit first check checks for the easy case of the current charmdir has a // git folder . // There can be cases when the charmdir actually uses git and is just a subdir // hence the below check
func usesGit(ctx context.Context, charmPath string, cancelFunc func()) bool {
	defer cancelFunc()
	if _, err := os.Stat(filepath.Join(charmPath, ".git")); err == nil {
		return true
	}
	args := []string{"rev-parse", "--is-inside-work-tree"}
	execCmd := exec.CommandContext(ctx, "git", args...)
	execCmd.Dir = charmPath
	_, err := execCmd.Output()
	if ctx.Err() == context.DeadlineExceeded {
		logger.Debugf("git command timed out for charm in path: %q", charmPath)
		return false
	}
	if err == nil {
		return true
	}
	return false
}
func usesGit ( ctx context . Context , charmPath string , cancelFunc func ( ) ) bool { defer cancelFunc ( ) if _ , err := os . Stat ( filepath . Join ( charmPath , " " ) ) ; err == nil { return true } args := [ ] string { " " , " " } execCmd := exec . CommandContext ( ctx , " " , args ... ) execCmd . Dir = charmPath _ , err := execCmd . Output ( ) if ctx . Err ( ) == context . DeadlineExceeded { logger . Debugf ( " " , charmPath ) return false } if err == nil { return true } return false }
usesGit first check checks for the easy case of the current charmdir has a
git folder.
usesGit first check checks for the easy case of the current charmdir has a git folder .