Repository: buildbot/buildbot

Issue:
gitlab change_status webhook doesn't properly detect changes
This ticket is a migrated Trac ticket [3031](http://trac.buildbot.net/ticket/3031)

People contributed to the original ticket: `vlovich@...`, @djmitche
Ticket created on: `Nov 16 2014`
Ticket last modified on: `Nov 16 2014`

---

GitLab only sends out commit information for objects new to the repository & branch.  New branches do not contain commits.
Resetting the branch to a different point does not contain commits.

For example:

        git reset --hard HEAD^
        git push origin

Buildbot reports no new changes even though gitlab said there was a different before & after.

        git push origin HEAD:some_branch
        git push origin HEAD:some_other_branch

Buildbot reports no new changes even though gitlab said there was a different before & after.

The point is that there should be a change emitted even if there are no "new" commits


---

_Comment from_: @unknown_contributor
_Date_: `Nov 16 2014`

Example payloads.

Head reset to an existing commit:

        {'user_id': 438,
         'repository': {
             'url': 'git@<repository>.git',
             'homepage': 'https://<gitlab url>',
             'name': '<project>',
             'description': None },
          'user_name': '<name>',
          'after': u'0734e36f1af7cce5dff46f8ebd5802c66839ecae',
          'total_commits_count': 0,
          'commits': [],
          'project_id': 534,
          'ref': 'refs/heads/<branch>',
          'before': u'afeebec3acdf0d2fc7d786f4f013e9bfc733305a'
        }


New branch:

        {'user_id': 438,
         'repository': {
             'url': 'git@<repository>.git',
             'homepage': 'https://<gitlab url>', 
             'name': '<project>', 
             'description': None},
         'user_name': '<name>', 
         'after': '0734e36f1af7cce5dff46f8ebd5802c66839ecae',
         'total_commits_count': 0, 
         'commits': [],
         'project_id': 534,
         'ref': 'refs/heads/<branch>',
         'before': u'0000000000000000000000000000000000000000'}


Existing gitLab issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/490

The reason I think buildbot needs to solve this is that gitlab might not be able to as what is the set of new commits when you reset the head?  I think the Gitlab webhook in buildbot should generate faux changes in this scenario.

---
_Comment from_: @dustin
_Date_: `Nov 16 2014`

I'm confused about how Buildbot can solve a [[GitLab]] bug.  What would the Buildbot change look like in this case, and where would it get the necessary information if not from the [[GitLab]] POST?

---
_Comment from_: @unknown_contributor
_Date_: `Nov 16 2014`

It's not a Gitlab bug per se.  For example, on a new branch, what could they list?  The entire commit history of master?  Maybe you could try detecting an existing branch you branched off of & find the new commits there.

Buildbot could generate a change regardless.  It wouldn't have any information, but at least it would get tested properly.




Discussion:

Resolving patch:
diff --git a/master/buildbot/schedulers/timed.py b/master/buildbot/schedulers/timed.py
--- a/master/buildbot/schedulers/timed.py
+++ b/master/buildbot/schedulers/timed.py
@@ -143,7 +143,7 @@ def startBuild(self):
         # important changes have occurred since the last invocation
         if self.onlyIfChanged and not any(itervalues(classifications)):
             log.msg(("%s scheduler <%s>: skipping build " +
-                     "- No important changes on configured branch") %
+                     "- No important changes") %
                     (self.__class__.__name__, self.name))
             return
 


Test patch: