MCPcopy
hub / github.com/cli/cli / guessGistName

Function guessGistName

pkg/cmd/gist/create/create.go:243–260  ·  view source on GitHub ↗
(files map[string]*shared.GistFile)

Source from the content-addressed store, hash-verified

241}
242
243func guessGistName(files map[string]*shared.GistFile) string {
244 filenames := make([]string, 0, len(files))
245 gistName := ""
246
247 re := regexp.MustCompile(`^gistfile\d+\.txt$`)
248 for k := range files {
249 if !re.MatchString(k) {
250 filenames = append(filenames, k)
251 }
252 }
253
254 if len(filenames) > 0 {
255 sort.Strings(filenames)
256 gistName = filenames[0]
257 }
258
259 return gistName
260}
261
262func createGist(client *http.Client, hostname, description string, public bool, files map[string]*shared.GistFile) (*shared.Gist, error) {
263 body := &shared.Gist{

Callers 3

Test_guessGistName_stdinFunction · 0.85
createRunFunction · 0.85

Calls

no outgoing calls

Tested by 2

Test_guessGistName_stdinFunction · 0.68