MCPcopy Create free account
hub / github.com/bluekeyes/patch2pr / makeInput

Method makeInput

graphql_applier.go:309–357  ·  view source on GitHub ↗
(ref string, header *gitdiff.PatchHeader)

Source from the content-addressed store, hash-verified

307}
308
309func (a *GraphQLApplier) makeInput(ref string, header *gitdiff.PatchHeader) githubv4.CreateCommitOnBranchInput {
310 branch := githubv4.String(ref)
311 repoNameWithOwner := githubv4.String(fmt.Sprintf("%s/%s", a.owner, a.repo))
312
313 input := githubv4.CreateCommitOnBranchInput{
314 Branch: githubv4.CommittableBranch{
315 BranchName: &branch,
316 RepositoryNameWithOwner: &repoNameWithOwner,
317 },
318 ExpectedHeadOid: githubv4.GitObjectID(a.commit),
319 Message: githubv4.CommitMessage{
320 Headline: githubv4.String(DefaultCommitMessage),
321 },
322 FileChanges: &githubv4.FileChanges{},
323 }
324
325 if header != nil {
326 input.Message.Headline = githubv4.String(header.Title)
327 if header.Body != "" {
328 body := githubv4.String(header.Body)
329 input.Message.Body = &body
330 }
331 }
332
333 var dels []githubv4.FileDeletion
334 var adds []githubv4.FileAddition
335 for path, change := range a.changes {
336 switch {
337 case change.IsDelete:
338 dels = append(dels, githubv4.FileDeletion{
339 Path: githubv4.String(path),
340 })
341 default:
342 content := base64.StdEncoding.EncodeToString(change.Content)
343 adds = append(adds, githubv4.FileAddition{
344 Path: githubv4.String(path),
345 Contents: githubv4.Base64String(content),
346 })
347 }
348 }
349 if len(dels) > 0 {
350 input.FileChanges.Deletions = &dels
351 }
352 if len(adds) > 0 {
353 input.FileChanges.Additions = &adds
354 }
355
356 return input
357}
358
359// Reset resets the applier so that future Apply calls start from commit base.
360// It removes all pending file changes. Reset does not modify the repository.

Callers 1

CommitMethod · 0.95

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected