Skip to content
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

Feature/scmm pr handling #50

Merged
merged 21 commits into from
Feb 8, 2021
Merged

Feature/scmm pr handling #50

merged 21 commits into from
Feb 8, 2021

Conversation

pmarkiewka
Copy link
Contributor

Implements pull request handling for the SCM-Manager

Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
pmarkiewka and others added 3 commits January 21, 2021 23:28
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
Don't expose methods that return SCM-Mananger specific data, as we might want to abstract a SCM interface that might be implemented by SCM-Manager, GitHub, etc.
httpCode = httpCode.trim()
script.echo "Creating pull request yields httpCode: ${httpCode}"
if (httpCode != "201") {
script.unstable 'Could not create pull request'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more versatile to return false here?
This way the caller can decide what to do about it.

We could even think about adding a createOrUpdate() method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the execution continues after the unstable call!
That is, it causes an exception java.lang.NullPointerException: Cannot invoke method split() on null object because the following is still executed return httpResponse.headers.location.split("/")[-1]

Copy link
Member

@schnatterer schnatterer Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NPE is fixed in 740516b .

Still open:

  • not use unstable?
  • createOrUpdate() method?

README.md Outdated Show resolved Hide resolved
We have needed this several times in libs and also in Jenkinsfiles.

In addition implementing it inside a functional class such as Git or SCMManager, is the opposite of separation of concerns.
"java.lang.NullPointerException: Cannot invoke method split() on null object" cause by ongoing control flow after script.unstable.
@schnatterer schnatterer force-pushed the feature/scmm_pr_handling branch from 5016ef9 to 5bf1c43 Compare January 28, 2021 12:02
schnatterer and others added 5 commits January 28, 2021 14:38
Use HttpClient mock and JsonOutput instead of raw curl outputs.
Allows for extension, not just PRs.

Also extends test:
- also assert URLs, content type and body
- removes unit tests for protected method (it's only used internally, is is tested via public API)
Signed-off-by: Marek Markiewka <marek.markiewka@cloudogu.com>
… unstable

Signed-off-by: Philipp Markiewka <philipp.markiewka@cloudogu.com>
@marekzan marekzan merged commit ddd8f19 into develop Feb 8, 2021
@marekzan marekzan deleted the feature/scmm_pr_handling branch February 8, 2021 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants