Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Add project view command #778

Merged
merged 9 commits into from
Jul 4, 2021
Merged

Conversation

brodock
Copy link
Contributor

@brodock brodock commented Jul 1, 2021

Description
Adds glab project view [repository] [flags] command.

View, will render project name, description and README. Optionally you can pass --web and it will open the project in your default browser instead.

If you don't pass a repository path, it will try to infer based on current git repository. If it finds, it will also use current branch to retrieve the README from, or to open the browser project page within that branch.

It also accepts just a repository name without a namespace, in which it will use your own username as the namespace.

Ex: glab project view glab will open the brodock/glab in my case.

Related Issue
Resolves #777

How Has This Been Tested?

I've only tested this manually. Will work on adding go tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)

Usage: glab project view [repository] [--web]

Will either display project name, description and README
or open the URL in the default browser.

If repository is not informed it will try to get from current git
and will use current branch.
@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #778 (e4cb0f0) into trunk (952d3a2) will decrease coverage by 0.13%.
The diff coverage is 10.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk     #778      +/-   ##
==========================================
- Coverage   58.47%   58.34%   -0.14%     
==========================================
  Files          93       93              
  Lines        6681     6696      +15     
==========================================
  Hits         3907     3907              
- Misses       2395     2409      +14     
- Partials      379      380       +1     
Impacted Files Coverage Δ
pkg/utils/utils.go 30.23% <0.00%> (-5.39%) ⬇️
internal/glrepo/repo.go 83.49% <33.33%> (-1.80%) ⬇️
commands/project/repo.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 952d3a2...e4cb0f0. Read the comment docs.

Copy link
Owner

@profclems profclems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @brodock for working on this! This is great!

Just some few stuff to fix up.

commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Outdated Show resolved Hide resolved
commands/project/view/project_view.go Show resolved Hide resolved
Copy link
Owner

@profclems profclems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good! Thanks a lot @brodock

@brodock brodock marked this pull request as draft July 1, 2021 23:46
@brodock
Copy link
Contributor Author

brodock commented Jul 1, 2021

I've made it into a draft as I found a few edge cases, I will be looking at it tomorrow.
For example, if I type glab repo view somerepo while outside a repository (like when in the home directory), it fails because of the first call to f.Branch(). So I need to bypass a few things when not in a repository

@brodock brodock marked this pull request as ready for review July 2, 2021 16:39
@brodock brodock requested a review from profclems July 2, 2021 16:39
@brodock
Copy link
Contributor Author

brodock commented Jul 2, 2021

@profclems this is ready for review again

Adding support for allowing users enter full URLs to project path.
This will allows users override the repo host and protocol.

Examples:
- glab repo view [email protected]:profclems/glab.git
- glab repo view https://gitlab.company.org/user/repo
- glab repo view https://gitlab.company.org/user/repo.git
@profclems
Copy link
Owner

I have added a few commits to add support for full URLs to allow users specify the repo [git] url as argument.

This will allows users override the repo host and protocol.

Examples:

  • glab repo view [email protected]:profclems/glab.git
  • glab repo view https://gitlab.company.org/user/repo
  • glab repo view https://gitlab.company.org/user/repo.git

@profclems profclems merged commit 218cd95 into profclems:trunk Jul 4, 2021
@brodock
Copy link
Contributor Author

brodock commented Jul 6, 2021

@profclems I've tested the last changes, and it seems it added an unexpected behavior: when I type glab repo view gitlab-org/gitlab --web from my current glab branch, it will open gitlab-org/gitlab using that branch instead of using default from API.

I will make a new PR to fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project view command
2 participants