MCPcopy Create free account
hub / github.com/cli/cli / CurrentUsername

Method CurrentUsername

pkg/cmd/status/status.go:218–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216}
217
218func (s *StatusGetter) CurrentUsername() (string, error) {
219 s.usernameMu.Lock()
220 defer s.usernameMu.Unlock()
221
222 if s.currentUsername != "" {
223 return s.currentUsername, nil
224 }
225
226 cachedClient := s.CachedClient(time.Hour * 48)
227 cachingAPIClient := api.NewClientFromHTTP(cachedClient)
228 currentUsername, err := api.CurrentLoginName(cachingAPIClient, s.hostname())
229 if err != nil {
230 return "", fmt.Errorf("failed to get current username: %w", err)
231 }
232
233 s.currentUsername = currentUsername
234 return currentUsername, nil
235}
236
237func (s *StatusGetter) ActualMention(commentURL safeurl.SafeURL) (string, error) {
238 currentUsername, err := s.CurrentUsername()

Callers 2

ActualMentionMethod · 0.95
LoadEventsMethod · 0.95

Calls 3

CachedClientMethod · 0.95
hostnameMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected