Refined-github: `deep-blame` doesn't support renamed files

Created on 28 Mar 2020  Â·  9Comments  Â·  Source: sindresorhus/refined-github

Feature: https://github.com/sindresorhus/refined-github/pull/2881

  1. Visit https://github.com/sindresorhus/refined-github/blame/fad67fb8d8fcf608601c9b8ae1b5f12337cbccce/source/options.html#L1
  2. Click Deep Blame button
  3. See 404 page

The file is currently source/options.html but was renamed twice.

The link we generate should point to the file that existed at the time: extension/options/index.html

The regular blame follows renames, but I'm not sure we (deep-blame) can.

bug help wanted

All 9 comments

@fregante I'll look into it tomorrow

@fregante looked into it. I dont see a way

Yeah when we implemented the “follow renames” feature we had to pull the rename commit specifically and get the new name from there.

Here we don’t know that commit at all, and even then there may be more than one.

One thing we can do to avoid opening a 404 page is to check the filenames in the PR first. If !associatedPr.fileList.includes(currentFile), alert(file was renamed)

Hmm, That would not work if the PR had more than 100 files No?

Yeah that'd break this feature on some 100+ files PRs. Maybe not worth the change

Is it possible to reach the file from the PR? Not just the files that the PR touches.

Example: associatedPr.lastCommit.tree.file(name: currentFileName)

Yes but you would have the same issue if more than 100 files were changed For example #2925

Not just the files that the PR touches.

👆

Yep, possible:

{
  repository(owner: "sindresorhus", name: "refined-github") {
    # New
    file: object(expression: "1bd2494431d9ddc26ad27f9c32b1c8d711f3b263:source/options.html") {
      ... on Blob {
        id
      }
    }

    # Same as before
    commit: object(expression: "1bd2494431d9ddc26ad27f9c32b1c8d711f3b263") {
      ... on Commit {
        associatedPullRequests(last: 1) {
          nodes {
            number
            mergeCommit {
              oid
            }
            commits(last: 1) {
              nodes {
                commit {
                  oid
                }
              }
            }
          }
        }
      }
    }
  }
}

In this case file: null because the file didn't exist on that commit

Ok will send a PR in a few

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hkdobrev picture hkdobrev  Â·  3Comments

sindresorhus picture sindresorhus  Â·  3Comments

hkdobrev picture hkdobrev  Â·  3Comments

Arcanemagus picture Arcanemagus  Â·  3Comments

durka picture durka  Â·  3Comments