-
Type:
Bug
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Component/s: git-client-plugin, git-plugin
-
Labels:None
-
Similar Issues:
Reproduction scenrario:
create 2 remote branches in "origin"
1) 1 - called bug/namespace/master
2) 2 - called namespace/master
Setup the projec to poll scm (every minute) and to build the branch namespace/master.
Expected result: if there are no changes in namespace/master it wont get rebuilt.
Actual: branch is constantly rebuilt
the problem is in git-client since the command
git ls-remote <uri> namespace/master will return you both branch revisions and take the first one ..
buggy method is :
CliGitAPIImpl:
public ObjectId getHeadRev(String url, String branchSpec) throws GitException, InterruptedException
{ final String branchName = extractBranchNameFromBranchSpec(branchSpec); ArgumentListBuilder args = new ArgumentListBuilder("ls-remote"); args.add("-h"); StandardCredentials cred = credentials.get(url); if (cred == null) cred = defaultCredentials; args.add(url); args.add(branchName); String result = launchCommandWithCredentials(args, null, cred, url); return result.length()>=40 ? ObjectId.fromString(result.substring(0, 40)) : null; }
That is an unfortunate side effect of the design decision made long ago to split on the slash in the "branch to build". I'm not willing to break compatibility with that old design decision because of the number of users of the git plugin (and the git client plugin) and the many ways in which they depend on those plugins.
Rather than break compatibility, Alexander Link has proposed that we accept "refs/heads/namespace/master" as an intentional declaration of the specific branch, without changing the semantics of other forms (like origin/master, */master).
Would you be willing to assist with the evaluation of Alexander's proposed changes? They are included in https://github.com/jenkinsci/git-client-plugin/pull/135