MCPcopy Index your code
hub / github.com/github/gh-aw / getRepositorySlugFromRemoteForPath

Function getRepositorySlugFromRemoteForPath

pkg/cli/git.go:290–311  ·  view source on GitHub ↗

getRepositorySlugFromRemoteForPath extracts the repository slug (owner/repo) from the git remote URL of the repository containing the specified file path. It prefers the 'upstream' remote when available, and otherwise follows standard remote resolution (origin first, then single-remote fallback).

(path string)

Source from the content-addressed store, hash-verified

288// It prefers the 'upstream' remote when available, and otherwise follows standard
289// remote resolution (origin first, then single-remote fallback).
290func getRepositorySlugFromRemoteForPath(path string) string {
291 gitLog.Printf("Getting repository slug for path: %s", path)
292
293 // Get absolute path first
294 absPath, err := filepath.Abs(path)
295 if err != nil {
296 gitLog.Printf("Failed to get absolute path: %v", err)
297 return ""
298 }
299
300 // Validate the absolute path
301 absPath, err = fileutil.ValidateAbsolutePath(absPath)
302 if err != nil {
303 gitLog.Printf("Invalid path: %v", err)
304 return ""
305 }
306
307 // Use the directory containing the file
308 dir := filepath.Dir(absPath)
309
310 return getRepositorySlugFromDirPreferringUpstream(dir)
311}
312
313func stageWorkflowChanges() {
314 // Find git root and add .github/workflows relative to it

Calls 3

ValidateAbsolutePathFunction · 0.92
PrintfMethod · 0.45