1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-11-06 09:09:19 +02:00

Adapt request body for SAP_COM_0948 (#4865)

* Adapt request body for SAP_COM_0948

* Adapt tests

* Readd tags
This commit is contained in:
Daniel Mieg
2024-03-14 16:30:19 +01:00
committed by GitHub
parent 4d86308433
commit 6e9f52e274
3 changed files with 13 additions and 4 deletions

View File

@@ -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")
}
@@ -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

View File

@@ -269,7 +269,7 @@ 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{
@@ -277,7 +277,7 @@ func TestCreateRequestBodies(t *testing.T) {
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) {

View File

@@ -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)