Home / File/ update-commit-message.js — react Source File

update-commit-message.js — react Source File

Architecture documentation for update-commit-message.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * INSTALLATION:
 *   - `$ npm install octokit
 *   - Get a token from https://github.com/settings/tokens for use in the command below,
 *     set the token value as the GITHUB_AUTH_TOKEN environment variable
 *
 *  USAGE:
 *   - $ GITHUB_AUTH_TOKEN="..." git filter-branch -f --msg-filter "node update-commit-message.js" 2364096862b72cf4d801ef2008c54252335a2df9..HEAD
 */

const {Octokit, App} = require('octokit');
const fs = require('fs');

const OWNER = 'facebook';
const REPO = 'react-forget';
const octokit = new Octokit({auth: process.env.GITHUB_AUTH_TOKEN});

const fetchPullRequest = async pullNumber => {
  const response = await octokit.request(
    'GET /repos/{owner}/{repo}/pulls/{pull_number}',
    {
      owner: OWNER,
      repo: REPO,
      pull_number: pullNumber,
      headers: {
        'X-GitHub-Api-Version': '2022-11-28',
      },
    }
  );
  return {body: response.data.body, title: response.data.title};
};

function formatCommitMessage(str) {
  let formattedStr = '';
  let line = '';

  const trim = str.replace(/(\r\n|\n|\r)/gm, ' ').trim();
  if (!trim) {
    return '';
  }

  // Split the string into words
  const words = trim.split(' ');
  // Iterate over each word
  for (let i = 0; i < words.length; i++) {
    // If adding the next word doesn't exceed the line length limit, add it to the line
    if ((line + words[i]).length <= 80) {
      line += words[i] + ' ';
    } else {
      // Otherwise, add the line to the formatted string and start a new line
      formattedStr += line + '\n';
      line = words[i] + ' ';
    }
  }
  // Add the last line to the formatted string
// ... (88 more lines)

Domain

Subdomains

Frequently Asked Questions

What does update-commit-message.js do?
update-commit-message.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in update-commit-message.js?
update-commit-message.js defines 5 function(s): fetchPullRequest, filterMsg, formatCommitMessage, main, parsePullRequestNumber.
Where is update-commit-message.js in the architecture?
update-commit-message.js is located at compiler/scripts/update-commit-message.js (domain: BabelCompiler, subdomain: Optimization, directory: compiler/scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free