Skip to content

feat: [PIPE-23808]: integrate author details with the harness commits API #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scm/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ type (
// Find returns the repository file content by path.
Find(ctx context.Context, repo, path, ref string) (*Content, *Response, error)

// Create creates a new repositroy file.
// Create creates a new repository file.
Create(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)

// Update updates a repository file.
Update(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)

// Delete deletes a reository file.
// Delete deletes a repository file.
Delete(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)

// List returns a list of contents in a repository directory by path. It is
Expand Down
196 changes: 99 additions & 97 deletions scm/driver/harness/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (s *contentService) Create(ctx context.Context, repo, path string, params *
Title: params.Message,
Actions: []action{a},
BypassRules: true,
Author: identity{
Name: params.Signature.Name,
Email: params.Signature.Email,
},
}

res, err := s.client.do(ctx, "POST", endpoint, in, nil)
Expand All @@ -81,6 +85,10 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
Title: params.Message,
Actions: []action{a},
BypassRules: true,
Author: identity{
Name: params.Signature.Name,
Email: params.Signature.Email,
},
}

res, err := s.client.do(ctx, "POST", endpoint, in, nil)
Expand All @@ -105,6 +113,10 @@ func (s *contentService) Delete(ctx context.Context, repo, path string, params *
Title: params.Message,
Actions: []action{a},
BypassRules: true,
Author: identity{
Name: params.Signature.Name,
Email: params.Signature.Email,
},
}

res, err := s.client.do(ctx, "POST", endpoint, in, nil)
Expand All @@ -123,109 +135,99 @@ func (s *contentService) List(ctx context.Context, repo, path, ref string, _ scm
return convertContentInfoList(out.Content.Entries), res, err
}

type editFile struct {
Actions []action `json:"actions"`
Branch string `json:"branch"`
Message string `json:"message"`
NewBranch string `json:"new_branch"`
Title string `json:"title"`
type (
identity struct {
Name string `json:"name"`
Email string `json:"email"`
}

BypassRules bool `json:"bypass_rules"`
}
editFile struct {
Actions []action `json:"actions"`
Author identity `json:"author"`
Branch string `json:"branch"`
Message string `json:"message"`
NewBranch string `json:"new_branch"`
Title string `json:"title"`

type action struct {
Action string `json:"action"`
Encoding string `json:"encoding"`
Path string `json:"path"`
Payload string `json:"payload"`
Sha string `json:"sha"`
}
BypassRules bool `json:"bypass_rules"`
}

type fileContent struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
Content struct {
action struct {
Action string `json:"action"`
Encoding string `json:"encoding"`
Data string `json:"data"`
Size int `json:"size"`
} `json:"content"`
}
Path string `json:"path"`
Payload string `json:"payload"`
Sha string `json:"sha"`
}

type contentList struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
Content struct {
Entries []fileEntry `json:"entries"`
} `json:"content"`
}
fileContent struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
Content struct {
Encoding string `json:"encoding"`
Data string `json:"data"`
Size int `json:"size"`
} `json:"content"`
}

type fileEntry struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
}
contentList struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
Content struct {
Entries []fileEntry `json:"entries"`
} `json:"content"`
}

fileEntry struct {
Type string `json:"type"`
Sha string `json:"sha"`
Name string `json:"name"`
Path string `json:"path"`
LatestCommit struct {
Sha string `json:"sha"`
Title string `json:"title"`
Message string `json:"message"`
Author struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"author"`
Committer struct {
Identity identity `json:"identity"`
When time.Time `json:"when"`
} `json:"committer"`
} `json:"latest_commit"`
}
)

func convertContentInfoList(from []fileEntry) []*scm.ContentInfo {
to := []*scm.ContentInfo{}
Expand Down