Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work for self hosted github enterprise? #2

Closed
acastro2 opened this issue Jan 27, 2022 · 5 comments
Closed

Doesn't work for self hosted github enterprise? #2

acastro2 opened this issue Jan 27, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@acastro2
Copy link

acastro2 commented Jan 27, 2022

I think it doesn't work for self-hosted github enterprise. The URL here is git..com (only vpn accessible), and when running mkdocs serve:

INFO     -  Multirepo plugin is importing docs for section Section 1
[Errno 2] No such file or directory: 'where'

This is an example of the mkdocs.yml:

# Project information
site_name: Platform Wiki
site_description: Centralized location for all documentation
site_author: Platform

# Repository
repo_name: platform/centralized-docs
repo_url: https://git.<company>.com/platform/centralized-docs

nav:
  - Home: index.md
  - Login Server: '!import https://git.<company>.com/<org>/<repo>@master'

# Configuration
theme:
  name: material
  palette:
    primary: indigo
    accent: pink
    scheme: default

plugins:
  - multirepo:
      # (optional) tells multirepo to cleanup the temporary directory after site is built.
      cleanup: true
      # (optional) tells multirepo what the temp directory should be called
      temp_dir: multirepo_docs
@jdoiro3 jdoiro3 added the bug Something isn't working label Jan 31, 2022
@jdoiro3
Copy link
Owner

jdoiro3 commented Feb 1, 2022

I'll need to look into this more deeply but it might be because I updated the import syntax. Instead of @{branch} it's now ?branch={branch}. You can read more here for details. Let me know if you still encounter the same error. I'm planning on writing tests pretty soon.

@froschdesign
Copy link

froschdesign commented Feb 18, 2022

@jdoiro3
I have the same problem when I test the plugin on my local machine (macOS):

INFO     -  Building documentation...
INFO     -  Multirepo plugin importing docs...
[Errno 2] No such file or directory: 'where'

The problem is the detection of Git:

output = (
subprocess.run(["where", "git"], **extra_run_args)
.stdout
.replace("\r", "") # remove carrage return
.split("\n")[0] # handle multiple locations of git.exe
)

This works for me:

output = (
    subprocess.run('which git', capture_output=True, text=True, shell=True)
        .stdout
        .replace("\r", "")  # remove carrage return
        .split("\n")[0]  # handle multiple locations of git.exe
)

pprint(output) # /usr/local/git/bin/git

But the detection of the Git version is the next problem:

version = search(r'([\d.]+)', stdout).group(1).split(".")[:2]
AttributeError: 'NoneType' object has no attribute 'group'

version = search(r'([\d.]+)', stdout).group(1).split(".")[:2]


Maybe it would help to use a library for handling Git, like GitPython.

@jdoiro3
Copy link
Owner

jdoiro3 commented Feb 18, 2022

@froschdesign, thanks for looking into this. I'm pretty sure I know what's going on and how to resolve this issue. The below function only checks for Linux and not macOS, leading to where git being called which isn't a macOS command.

def execute_bash_script(script: str, arguments: list = [], cwd: Path = Path.cwd()) -> subprocess.CompletedProcess:
"""executes a bash script"""
extra_run_args = get_subprocess_run_extra_args()
if platform == "linux" or platform == "linux2":
process = subprocess.run(
["bash", script]+arguments, cwd=cwd, **extra_run_args
)
else:
git_folder = where_git()
process = subprocess.run(
[str(git_folder / "bin" / "bash.exe"), script]+arguments, cwd=cwd, **extra_run_args
)
return process

Also - that's 100% a good idea but didn't go with GitPython it didn't support the advance features like sparse clone or the --depth argument, which are optimizations.

I'll go ahead and make some changes pretty soon and also add macOS to my testing.

@jdoiro3
Copy link
Owner

jdoiro3 commented Feb 19, 2022

I just pushed changes that fixed this bug. Versions at or above v0.2.9 should work on macOS. I was able to confirm the bug and fix with another macOS machine.

@froschdesign or @acastro2, can one of you confirm it works on your end?

@froschdesign
Copy link

@jdoiro3
Works great! 👍

@jdoiro3 jdoiro3 closed this as completed Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants