Skip to content

Commit

Permalink
feat: dctl project open git
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys committed Oct 29, 2023
1 parent 60b4e35 commit 17c67bf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ steps:
uses: actions/checkout@v3

- name: Setup dctl CLI
uses: deployplex/dctl@0.0.12
uses: deployplex/dctl@0.0.13
with:
token: ${{ secrets.DEPLOYPLEX_TOKEN }}
```
Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: python3 -m pip install dctl==0.0.12
- run: python3 -m pip install dctl==0.0.13
shell: bash
- run: echo "DEPLOYPLEX_TOKEN=${{ inputs.token }}" >> $GITHUB_ENV
if: ${{ inputs.token }}
Expand Down
2 changes: 2 additions & 0 deletions dctl/commands/project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import click
from dctl.commands.project.list import list
from dctl.commands.project.open import open


@click.group("project", help="Project commands")
Expand All @@ -8,3 +9,4 @@ def project():


project.add_command(list)
project.add_command(open)
30 changes: 30 additions & 0 deletions dctl/commands/project/open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import click
import os
import webbrowser
import configparser


@click.group("open", help="Project open commands")
def open():
pass


@open.command(name="git", help="Open project git repository")
def open_git():
git_config_path = os.path.join(os.getcwd(), '.git', 'config')

if not os.path.exists(git_config_path):
raise click.ClickException("No .git folder found.")

config = configparser.ConfigParser()
config.read(git_config_path)

try:
url = config.get('remote "origin"', 'url')
if url.startswith("git@"):
url = url.replace(":", "/").replace("git@", "https://").replace(".git", "")
webbrowser.open(url)
except configparser.NoSectionError:
raise click.ClickException("Remote origin not found.")
except Exception as e:
raise click.ClickException(f"An error occurred: {e}")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dctl"
version = "0.0.12"
version = "0.0.13"
description = "Command Line Interface (CLI) for DeployPlex"
authors = ["Alvaro Molina <am@deployplex.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 17c67bf

Please sign in to comment.