Skip to content

Commit

Permalink
Adapt request body for SAP_COM_0948 (#4865)
Browse files Browse the repository at this point in the history
* Adapt request body for SAP_COM_0948

* Adapt tests

* Readd tags
  • Loading branch information
DanielMieg authored Mar 14, 2024
1 parent 4d86308 commit 6e9f52e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion pkg/abaputils/manageGitRepositoryUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (repo *Repository) GetLogStringForCommitOrTag() (logString string) {
return logString
}

func (repo *Repository) GetCloneRequestBody() (body string) {
func (repo *Repository) GetCloneRequestBodyWithSWC() (body string) {
if repo.CommitID != "" && repo.Tag != "" {
log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag")
}
Expand All @@ -211,6 +211,15 @@ func (repo *Repository) GetCloneRequestBody() (body string) {
return body
}

func (repo *Repository) GetCloneRequestBody() (body string) {
if repo.CommitID != "" && repo.Tag != "" {
log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag")
}
requestBodyString := repo.GetRequestBodyForCommitOrTag()
body = `{"branch_name":"` + repo.Branch + `"` + requestBodyString + `}`
return body
}

func (repo *Repository) GetCloneLogString() (logString string) {
commitOrTag := repo.GetLogStringForCommitOrTag()
logString = "repository / software component '" + repo.Name + "', branch '" + repo.Branch + "'" + commitOrTag
Expand Down
4 changes: 2 additions & 2 deletions pkg/abaputils/manageGitRepositoryUtils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ func TestCreateRequestBodies(t *testing.T) {
Tag: "myTag",
}
body := repo.GetCloneRequestBody()
assert.Equal(t, `{"sc_name":"/DMO/REPO", "branch_name":"main", "commit_id":"1234567"}`, body, "Expected different body")
assert.Equal(t, `{"branch_name":"main", "commit_id":"1234567"}`, body, "Expected different body")
})
t.Run("Clone Body Tag", func(t *testing.T) {
repo := Repository{
Name: "/DMO/REPO",
Branch: "main",
Tag: "myTag",
}
body := repo.GetCloneRequestBody()
body := repo.GetCloneRequestBodyWithSWC()
assert.Equal(t, `{"sc_name":"/DMO/REPO", "branch_name":"main", "tag_name":"myTag"}`, body, "Expected different body")
})
t.Run("Pull Body Tag and Commit", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/abaputils/sap_com_0510.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (api *SAP_COM_0510) Clone() error {

cloneConnectionDetails := api.con
cloneConnectionDetails.URL = api.con.URL + api.path + api.cloneEntity
body := []byte(api.repository.GetCloneRequestBody())
body := []byte(api.repository.GetCloneRequestBodyWithSWC())

return api.triggerRequest(cloneConnectionDetails, body)

Expand Down

0 comments on commit 6e9f52e

Please sign in to comment.