Question about extending SCMFileSystem of SCM API

60 views
Skip to first unread message

Goyot, Martin

unread,
Sep 3, 2021, 11:01:35 AM9/3/21
to jenkin...@googlegroups.com
Hi there,

I'm trying to implement a *branch-source* style plugin and I'm a bit lost about the SCMFileSystem implementation and its connection with the `getTrustedRevision` from AbstractGitSCMSource. In my understanding getTrustedRevision should return a revision according to the implemented authorities. This revision is then passed to the SCMFileSystem.build().

In this method, I recieve two things; a head and a revision:

* Which one should I build upon ? Is it the revision or the head ? Or both depending on the context ?
* More importantly, I've seen that the revision can be null. In which cases is this possible ? How can I end up with an empty revision ?

Thanks in advance,
Martin

Jesse Glick

unread,
Sep 23, 2021, 8:19:09 AM9/23/21
to Jenkins Dev
Sorry, just noticed today that this never got a reply.

On Fri, Sep 3, 2021 at 11:01 AM Goyot, Martin <martin...@enalean.com> wrote:
Which one should I build upon ? Is it the revision or the head ? Or both depending on the context ?

A revision (commit) is more specific than a head (ref) so use a revision if present, and ignore the head unless you need it for some auxiliary purpose.

I've seen that the revision can be null. In which cases is this possible ?

Do you mean in Builder.build? Did you actually observe a null parameter, or are just concerned by the method specification? I would just return null in such cases unless a use case comes up, though you can also retrieve the current head revision. The implementor’s guide does not seem to discuss `SCMFileSystem.Builder` in detail.

If in doubt, follow the example of `github-branch-source`.

Goyot, Martin

unread,
Sep 23, 2021, 8:32:55 AM9/23/21
to jenkin...@googlegroups.com
Hi Jesse,

Thanks for your answer, so that's what I thought. I was a bit worried because there was no @NonNull annotation on the method and was wondering which case it could be.

Thanks !

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2r_D%3DMiJnTPww9-uL5emHc70TD%3DLs%3D%3D_7%2B6KJqoqbn2g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages