Skip to content

Update tree and blob resolvers to accept ref_type

What does this MR do and why?

Update tree and blob resolvers to accept ref_type

Also propagate ref_type to blob and tree presenters so that routes so frontend code can continue depending on the rendered routes

This is the first of a series of MRs for addressing the issue of not being able to browse files when a tag and branch have the same name.

For context the other MRs:

How to set up and validate locally

  1. Create a project with a branch and tag with the same name
  2. Try graphql queries to see that the correct blobs and trees are rendered

Example queries

query testPaginatedTree {
  project(fullPath: "root/project-with-branch-and-tag-sharing-name") {
    id
    repository {
      paginatedTree(path: "/", ref: "ambiguous", refType: TAGS) {
        nodes {
          trees {
            nodes {
              id
              sha
              name
              flatPath
              type
              webPath
            }
          }
          blobs {
            nodes {
              id
              sha
              name
              flatPath
              type
              mode
              webPath
              lfsOid
            }
          }
        }
      }
    }
  }
}


query testTree {
  project(fullPath: "root/project-with-branch-and-tag-sharing-name") {
    id
    repository {
      tree(path: "/", ref: "ambiguous", refType: "HEADS") {
        trees {
          nodes {
            id
            sha
            name
            flatPath
            type
            webPath
          }
        }
        blobs {
          nodes {
            id
            sha
            name
            flatPath
            type
            mode
            webPath
            lfsOid
          }
        }
      }
    }
  }
}



query testBlob {
  project(fullPath: "root/project-with-branch-and-tag-sharing-name") {
    id
    repository {
      blobs(paths: "README.md", ref: "ambiguous", refType:"HEADS") {
        nodes {
          id
          webPath
          name
          size
          rawSize
          fileType
          language
          path
          blamePath
          editBlobPath
          gitpodBlobUrl
          ideEditPath
          forkAndEditPath
          ideForkAndEditPath
          codeNavigationPath
          projectBlobPathRoot
          forkAndViewPath
          environmentFormattedExternalUrl
          environmentExternalUrlForRouteMap
          canModifyBlob
          canCurrentUserPushToBranch
          archived
          storedExternally
          externalStorage
          externalStorageUrl
          rawPath
          replacePath
          pipelineEditorPath
        }
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #20526 (closed)

Edited by Jerry Seto

Merge request reports

Loading