MCPcopy Create free account
hub / github.com/github/gh-aw / getOwnerNodeId

Function getOwnerNodeId

pkg/cli/project_command.go:261–287  ·  view source on GitHub ↗

getOwnerNodeId gets the node ID for the owner

(ctx context.Context, ownerType, owner string, verbose bool)

Source from the content-addressed store, hash-verified

259
260// getOwnerNodeId gets the node ID for the owner
261func getOwnerNodeId(ctx context.Context, ownerType, owner string, verbose bool) (string, error) {
262 projectLog.Printf("Getting node ID for %s: %s", ownerType, owner)
263 console.LogVerbose(verbose, fmt.Sprintf("Getting node ID for %s: %s", ownerType, owner))
264
265 var query string
266 var jqPath string
267 if ownerType == "org" {
268 query = fmt.Sprintf(`query { organization(login: "%s") { id } }`, escapeGraphQLString(owner))
269 jqPath = ".data.organization.id"
270 } else {
271 query = fmt.Sprintf(`query { user(login: "%s") { id } }`, escapeGraphQLString(owner))
272 jqPath = ".data.user.id"
273 }
274
275 output, err := workflow.RunGH("Getting owner ID...", "api", "graphql", "-f", "query="+query, "--jq", jqPath)
276 if err != nil {
277 return "", fmt.Errorf("failed to get owner node ID: %w", err)
278 }
279
280 nodeId := strings.TrimSpace(string(output))
281 if nodeId == "" {
282 return "", errors.New("failed to get owner node ID from response")
283 }
284
285 console.LogVerbose(verbose, "✓ Got node ID: "+nodeId)
286 return nodeId, nil
287}
288
289// createProject creates a GitHub Project V2
290func createProject(ctx context.Context, ownerId, title string, verbose bool) (map[string]any, error) {

Callers 1

RunProjectNewFunction · 0.85

Calls 5

LogVerboseFunction · 0.92
RunGHFunction · 0.92
escapeGraphQLStringFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected