if the latest commit ref for foo is abcde12345, and assuming a GitHub repository, the existing code would call repos/{slug}/contents//?ref=abcde12345 which would return the tree for the default branch. This is due to the extra / before the query string in the request. See the default when ref is omitted per the documentation - https://developer.github.com/v3/repos/contents/#get-contents
The expected behavior for a @cron (and with drone-tree-config) is to walk the entire tree for the branch configured in Drone.
In addition this PR applies the same fix when the change set does not include any changed files.
Last, it removes the / prefix which was applied in the code for plugin.getConfigForChanges(...)
Note: I have not tested this change with the bitbucket and gitlab SCM's. This said, the following documentation (and code) suggests that / as a prefix is also not expected, for them;
Git repo paths do not start with "/"
Prior to this fix, it was possible that a
@cron
associated with the non-default branch would return the incorrect config data.This PR fixes the following error;
given a repo, with a default (typically
master
) branch, that contains some tree;and a
@cron
established for the same repo, configured for branchfoo
, which contains a different tree;if the latest commit ref for
foo
isabcde12345
, and assuming a GitHub repository, the existing code would callrepos/{slug}/contents//?ref=abcde12345
which would return the tree for the default branch. This is due to the extra/
before the query string in the request. See the default whenref
is omitted per the documentation - https://developer.github.com/v3/repos/contents/#get-contentsThe expected behavior for a
@cron
(and with drone-tree-config) is to walk the entire tree for the branch configured in Drone./
prefix which was applied in the code forplugin.getConfigForChanges(...)
Note: I have not tested this change with the bitbucket and gitlab SCM's. This said, the following documentation (and code) suggests that
/
as a prefix is also not expected, for them;/
prefix -- https://github.com/bitsbeats/drone-tree-config/blob/master/plugin/scm_clients/gitlab_client.go#L127