GithubHelp home page GithubHelp logo

Comments (1)

adamsosterics avatar adamsosterics commented on June 15, 2024

This is something that I'd also like to see.
I'd like to add a review comment on Github for each commit that is not linked to an issue, but for that I also need to provide a path to a file that has been changed in that commit (see: https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request). For this usecase it doesn't really matter which file I'm putting the comment on.
A review comment is a bit better in this case than danger's message because the PR can't be merged until all review comments are resolved.
I'd like to write a dangerfile like this:

import { danger } from "danger";

const ISSUE_REFERENCE = `https://github.com/${danger.github.thisPR.owner}/${danger.github.thisPR.repo}/issues/`;

danger.git.commits.forEach((commit) => {
  if (!commit.message.includes(ISSUE_REFERENCE)) {
    danger.github.api.pulls.createReviewComment({
      owner: danger.github.thisPR.owner,
      repo: danger.github.thisPR.repo,
      pull_number: danger.github.thisPR.number,
      commit_id: commit.sha,
      body: "question: Do these changes belong to an issue?\n\nIf so, please add a reference to the issue in the commit messages.",
      path: commit.modified_files[0], // <--- note this
      side: "RIGHT",
      subject_type: "file",
    });
  }
});

from danger-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.