Skip to content

WIP: Download patch with code comments for unresolved discussions

Douwe Maan requested to merge dm-download-discussions-as-patch into master

/cc @rspeicher @smcgivern

Captura_de_pantalla_2018-09-24_a_la_s__10.45.55

Captura_de_pantalla_2018-09-24_a_la_s__10.46.04

Example patch:

From 85b8d925ee0841cb281d4e9e9b84389efea25ea6 Mon Sep 17 00:00:00 2001
From: Administrator <me@douwe.me>
Date: Mon, 24 Sep 2018 11:12:54 +0100
Subject: [PATCH] FIXME: Add code comments for unresolved discussions

This patch adds a code comment for every unresolved discussion on the
latest version of the diff of gitlab-org/gitlab-ce!1.

This commit was automatically generated by GitLab. Be sure to remove it
from the merge request branch before it is merged.
---
 lib/gitlab/user_access.rb           | 9 +++++++++
 spec/lib/gitlab/user_access_spec.rb | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 40d8c4bbf00..38b3aa6a48b 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -30,9 +30,18 @@ module Gitlab
       return false unless user
 
       if (project.protected_branch?(ref) && !project.developers_can_push_to_protected_branch?(ref)) || project.empty_repo?
+      # FIXME: Administrator (@root) started a discussion on the preceding line:
+      #   I suggest splitting this up into two lines; this is getting pretty hard to read.
+      #
+      # FIXME: Administrator (@root) commented:
+      #   More specifically, I think we can move the left hand side of `||` into a local variable defined on its own line.
+      #
         user.can?(:push_code_to_protected_branches, project)
       else
         user.can?(:push_code, project)
+        # FIXME: Administrator (@root) started a discussion on the preceding line:
+        #   I really dislike the way `user.can?(...)` looks; I far prefer `can?(user, ...)`.
+        #
       end
     end
 
diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb
index ab9b1541542..170faec62bf 100644
--- a/spec/lib/gitlab/user_access_spec.rb
+++ b/spec/lib/gitlab/user_access_spec.rb
@@ -37,6 +37,9 @@ describe Gitlab::UserAccess, lib: true do
         empty_project.team << [user, :developer]
 
         expect(project_access.can_push_to_branch?('master')).to be_falsey
+        # FIXME: Administrator (@root) started a discussion on the preceding line:
+        #   I don't love hard-coding `master`; what do you think about using `empty_project.default_branch`? Or wouldn't there be one because it's empty?
+        #
       end
     end
 
-- 
2.18.0

To do:

  • Backend
    • Cache commit
    • Support creation of multi-line comments
    • Comments in more languages
    • Specs
  • Frontend:
    • Improve text in modal
    • Use better icon in button
    • Don't display button when source branch is missing
  • Consider including discussions on deleted lines
  • Consider including outdated diff discussions
  • Consider including non-diff discussions
  • Consider including tasks from MR description
  • Docs
Edited by Douwe Maan

Merge request reports