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

Issues/47 multiple repos #74

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Issues/47 multiple repos #74

wants to merge 12 commits into from

Conversation

mhoffrog
Copy link
Collaborator

@mhoffrog mhoffrog commented Mar 19, 2022

#47
@ochurlaud - according to your proposal - please use this pull request for commenting your testing results. Many thanks for your efforts!
Please watch my recent commit of today where I added a restriction to limit the auto determination of git repos to the level of the global configured 'savedir'. Probable Git repos above this directory will be ignored.
@woolfg - FYI

lib/Git.php Outdated
2 => array('pipe', 'w'),
);
$pipes = array();
$command = Git::get_bin()." rev-parse --absolute-git-dir";
Copy link
Contributor

Choose a reason for hiding this comment

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

The command --absolute-git-dir was added in git 2.x. RHEL 7 (which is used by most companies that did not move to RHEL8 yet) still ships git 1.8 (yes I know it's so much outdated).

I changed it to --git-dir and it worked well for me. would it be ok to use this one or to have a check on the git version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ochurlaud - --git-dir does not work in my environment, since it is finding a top most .git repo in the directory and not the repo on the nearest parent directory. In my case I have a .git repo in my DokuWiki root directory for this kind of test - and if I use rev-parse --git-dir, then it is ignoring the .git in my data/pages namespace and will get to the top most .git repo in the directory tree. Can you verify this also ?

Copy link
Collaborator Author

@mhoffrog mhoffrog Mar 20, 2022

Choose a reason for hiding this comment

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

@ochurlaud - I have to precise - my answer above was not fully correct. It was based on a test using realpath(<--git-dir result>). This does not work, since --git-dir is behaving different in two cases:

  1. we are commiting a page in a namespace having a .git path - e.g. nspace1/mypage.txt with nspace1/.git
  • in this case --git-dir is providing the relative path ".git"
  1. we are commiting a page in a sub-namespace - e.g. nspace1/subnspace/mypage.txt
  • in this case --git-dir is providing the absolute path "<DOKU_WIKI_ROOT>/data/pages/nspace1/.git

So in case 1. we would have to prepend $path of the git command to the --git-dir result to get the absolute path.

Can you confirm my findings ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it's what the got documentation states. I'll propose something to fit both needs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ochurlaud - did commit 5e5a67c for using --git-dir. It works so far on my test cases. Please have a look and check.

ochurlaud and others added 12 commits May 7, 2023 19:44
- improvements due to code review:
  - changed config 'initRepo' -> 'autoDetermineRepos' to leverage self explanation
  - added missing language description for this config

Fixes #47
- fix for auto determining the next parent repo path:
  - Git.php:
    - fixed type declaration of $plugin for null initialization
    - replaced method is_in_git_repo($path) by absolute_git_dir($path)
    - added method get_repo_path()
  - editcommit.php:
    - clear repoWorkDir in case of auto determined repo_path
    - add --work-tree option only, if repoWorkDir is not empty

Fixes #47
- editcommit.php:
  - streamlined the code of initRepo to improve readability
- editcommit.php:
  - another simplification of the code
  - made ->initRepo(...) work for both: a file path name as well as a directory path name
- editcommit.php, Git.php:
  - fixed issue for non git repo related paths in case of auto determining repos
- editcommit.php:
  - added a restriction not to use auto determined git repos found in directories above the DokuWiki configured $conf['savedir'].
- Git.php:
  - in case of auto determined repos:
    - use git rev-parse --git-dir option rather than --absolute-git-dir to support a maximum range of git versions
    - function absolute_git_dir($path):
      - extended the logic to ensure to return an absolute repo_path in any case
- editcommit.php:
  - improved to be backward compatible with existing single repo path configured installations
- improved description of config settings
- set default value to empty string for $conf['repoPath'] and $conf['repoWorkDir']
- changed position of config setting 'autoDetermineRepos' to be listed before 'repoPath'
- improved German description of config settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants