JENKINS-43507 added traits to a number of plugins.
In order to side-step the problem of determining what the common traits for discovery and other cross-implementation concerns should look like, code duplication was used.
The net result is that each of the implementations has duplicated code for:
- Discovering Branches
- Discovering Origin pull requests
- Discovering Fork pull requests
- Checking out over SSH
- Overriding webhook management
The intent is that these common traits can be moved into SCM API rather than duplicated by every SCM API implementation, but we need to determine the shape of these traits a bit better before that can take place as these traits so far are all effectively DVCS model traits.
Ideally seeing the shape of traits for Subversion, Perforce and perhaps Accurev or Clearcase would help clarify what is required of a common implementation.
There is also the question of how to make the common traits not look common, for example:
- Discover Branches: when used in Git or Mercurial, this probably does not need any options to be configured because these sources do not have the concept of pull requests. When used in GitHub, Bitbucket, Gitea, etc they do have the concept of pull requests and consequently there are multiple strategies that the user needs to select from.
In the ideal case we would have just one BranchDiscovery trait, when added to a Git or Mercurial source it would not show any configuration and when added to a GitHub / Bitbucket / Gitea source it would display the strategy selection drop down list.