-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gitlabCompareChanges test, update fixtures
- Loading branch information
1 parent
a112547
commit a9eff81
Showing
9 changed files
with
158 additions
and
125 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
source/platforms/gitlab/_tests/fixtures/getCompareChanges.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
[ | ||
{ | ||
"scope": "https://gitlab.com:443", | ||
"method": "GET", | ||
"path": "/api/v4/projects/gitlab-org%2Fgitlab-foss/repository/compare?from=50cd5d9b776848cf23f1fd1ec52789dbdf946185&to=28531ab43666b5fdf37e0a70db3bcbf7d3f92183", | ||
"body": "", | ||
"status": 200, | ||
"response": { | ||
"commit": { | ||
"id": "28531ab43666b5fdf37e0a70db3bcbf7d3f92183", | ||
"short_id": "28531ab4", | ||
"created_at": "2019-04-08T11:56:17.000+01:00", | ||
"parent_ids": ["575ec3af131e9c101edfc50ee563381b37c8076e"], | ||
"title": "Pick reviewers based on branch name", | ||
"message": "Pick reviewers based on branch name\n\nChange reviewer roulette to always pick the same reviewers for the same\nbranch name. We do this by:\n\n1. Making the branch name 'canonical' across CE and EE by stripping a\n leading 'ce-' or 'ee-' and a trailing '-ce' or '-ee'. If people are\n following our branch naming guidelines, this should give the same\n branch name in both repos.\n2. Converting the branch name to a stable integer by taking the integer\n form of its MD5.\n3. Passing that integer as a seed to Ruby's `Random` class, which 'may\n be used to ensure repeatable sequences of pseudo-random numbers\n between different runs of the program' (from the Ruby documentation).\n\nThe upshot is that the same branch name (in CE and EE) should always\npick the same reviewers, and those should be evenly distributed across\nthe set of possible reviewers due to the use of MD5.\n", | ||
"author_name": "Sean McGivern", | ||
"author_email": "sean@gitlab.com", | ||
"authored_date": "2019-04-08T11:44:57.000+01:00", | ||
"committer_name": "Sean McGivern", | ||
"committer_email": "sean@gitlab.com", | ||
"committed_date": "2019-04-08T11:56:17.000+01:00" | ||
}, | ||
"commits": [ | ||
{ | ||
"id": "575ec3af131e9c101edfc50ee563381b37c8076e", | ||
"short_id": "575ec3af", | ||
"created_at": "2019-04-08T11:56:17.000+01:00", | ||
"parent_ids": ["50cd5d9b776848cf23f1fd1ec52789dbdf946185"], | ||
"title": "Add issue links to Danger roulette comments", | ||
"message": "Add issue links to Danger roulette comments\n", | ||
"author_name": "Sean McGivern", | ||
"author_email": "sean@gitlab.com", | ||
"authored_date": "2019-04-08T10:50:39.000+01:00", | ||
"committer_name": "Sean McGivern", | ||
"committer_email": "sean@gitlab.com", | ||
"committed_date": "2019-04-08T11:56:17.000+01:00" | ||
}, | ||
{ | ||
"id": "28531ab43666b5fdf37e0a70db3bcbf7d3f92183", | ||
"short_id": "28531ab4", | ||
"created_at": "2019-04-08T11:56:17.000+01:00", | ||
"parent_ids": ["575ec3af131e9c101edfc50ee563381b37c8076e"], | ||
"title": "Pick reviewers based on branch name", | ||
"message": "Pick reviewers based on branch name\n\nChange reviewer roulette to always pick the same reviewers for the same\nbranch name. We do this by:\n\n1. Making the branch name 'canonical' across CE and EE by stripping a\n leading 'ce-' or 'ee-' and a trailing '-ce' or '-ee'. If people are\n following our branch naming guidelines, this should give the same\n branch name in both repos.\n2. Converting the branch name to a stable integer by taking the integer\n form of its MD5.\n3. Passing that integer as a seed to Ruby's `Random` class, which 'may\n be used to ensure repeatable sequences of pseudo-random numbers\n between different runs of the program' (from the Ruby documentation).\n\nThe upshot is that the same branch name (in CE and EE) should always\npick the same reviewers, and those should be evenly distributed across\nthe set of possible reviewers due to the use of MD5.\n", | ||
"author_name": "Sean McGivern", | ||
"author_email": "sean@gitlab.com", | ||
"authored_date": "2019-04-08T11:44:57.000+01:00", | ||
"committer_name": "Sean McGivern", | ||
"committer_email": "sean@gitlab.com", | ||
"committed_date": "2019-04-08T11:56:17.000+01:00" | ||
} | ||
], | ||
"diffs": [ | ||
{ | ||
"old_path": "danger/roulette/Dangerfile", | ||
"new_path": "danger/roulette/Dangerfile", | ||
"a_mode": "100644", | ||
"b_mode": "100644", | ||
"new_file": false, | ||
"renamed_file": false, | ||
"deleted_file": false, | ||
"diff": "@@ -1,5 +1,7 @@\n # frozen_string_literal: true\n \n+require 'digest/md5'\n+\n MESSAGE = <<MARKDOWN\n ## Reviewer roulette\n \n@@ -29,17 +31,22 @@ Please consider creating a merge request to\n for them.\n MARKDOWN\n \n-def spin(team, project, category)\n+def spin(team, project, category, branch_name)\n+ rng = Random.new(Digest::MD5.hexdigest(branch_name).to_i(16))\n+\n reviewers = team.select { |member| member.reviewer?(project, category) }\n traintainers = team.select { |member| member.traintainer?(project, category) }\n maintainers = team.select { |member| member.maintainer?(project, category) }\n \n # TODO: filter out people who are currently not in the office\n+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/57652\n+ #\n # TODO: take CODEOWNERS into account?\n+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/57653\n \n # Make traintainers have triple the chance to be picked as a reviewer\n- reviewer = (reviewers + traintainers + traintainers).sample\n- maintainer = maintainers.sample\n+ reviewer = (reviewers + traintainers + traintainers).sample(random: rng)\n+ maintainer = maintainers.sample(random: rng)\n \n \"| #{helper.label_for_category(category)} | #{reviewer&.markdown_name} | #{maintainer&.markdown_name} |\"\n end\n@@ -65,6 +72,12 @@ categories = changes.keys - [:unknown]\n # CSS Clean up MRs are reviewed using a slightly different process, so we\n # disable the review roulette for such MRs.\n if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_labels.include?('CSS cleanup')\n+ # Strip leading and trailing CE/EE markers\n+ canonical_branch_name = gitlab\n+ .mr_json['source_branch']\n+ .gsub(/^[ce]e-/, '')\n+ .gsub(/-[ce]e$/, '')\n+\n team =\n begin\n helper.project_team\n@@ -79,7 +92,7 @@ if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_l\n project = helper.project_name\n unknown = changes.fetch(:unknown, [])\n \n- rows = categories.map { |category| spin(team, project, category) }\n+ rows = categories.map { |category| spin(team, project, category, canonical_branch_name) }\n \n markdown(MESSAGE)\n markdown(CATEGORY_TABLE_HEADER + rows.join(\"\\n\")) unless rows.empty?\n" | ||
} | ||
], | ||
"compare_timeout": false, | ||
"compare_same_ref": false | ||
}, | ||
"rawHeaders": [ | ||
"Server", | ||
"nginx", | ||
"Date", | ||
"Tue, 25 Feb 2020 17:43:41 GMT", | ||
"Content-Type", | ||
"application/json", | ||
"Content-Length", | ||
"5859", | ||
"Connection", | ||
"close", | ||
"Cache-Control", | ||
"max-age=0, private, must-revalidate", | ||
"Etag", | ||
"W/\"ab8052cb9a009582d0fe4e988f5d668d\"", | ||
"Vary", | ||
"Origin", | ||
"X-Content-Type-Options", | ||
"nosniff", | ||
"X-Frame-Options", | ||
"SAMEORIGIN", | ||
"X-Request-Id", | ||
"FM1OBYEIHt9", | ||
"X-Runtime", | ||
"0.137387", | ||
"Strict-Transport-Security", | ||
"max-age=31536000", | ||
"Referrer-Policy", | ||
"strict-origin-when-cross-origin", | ||
"RateLimit-Limit", | ||
"600", | ||
"RateLimit-Observed", | ||
"1", | ||
"RateLimit-Remaining", | ||
"599", | ||
"RateLimit-Reset", | ||
"1582652681", | ||
"RateLimit-ResetTime", | ||
"Tue, 25 Feb 2020 17:44:41 GMT", | ||
"GitLab-LB", | ||
"fe-13-lb-gprd", | ||
"GitLab-SV", | ||
"localhost" | ||
] | ||
} | ||
] |
Oops, something went wrong.