This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Satellite repository integration
- Loading branch information
Showing
3 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# List the OCA satellite projects to merge into this repo | ||
# Format <repo identifier> <repo git url> <repo branch> | ||
|
||
# Examples | ||
# ======== | ||
# | ||
# To integrate the modules in the 'OCA/web' repository, use: | ||
# web | ||
# | ||
# To explicitely give the URL of a fork, and still use the version specified in | ||
# .travis.yml, use: | ||
# web https://github.com/OCA/web.git | ||
# | ||
# To provide both the URL and a branch, use: | ||
# web https://github.com/OCA/web.git branchname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# List the OCA satellite projects to merge into this repo | ||
# Format <repo identifier> <repo git url> <repo branch> | ||
|
||
integrated-repo https://github.com/OCA/maintainer-quality-tools.git test-dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,26 +56,55 @@ def parse_depfile(depsfile_path, owner='OCA'): | |
return deps | ||
|
||
|
||
def git_checkout(deps_checkout_dir, reponame, url, branch): | ||
checkout_dir = osp.join(deps_checkout_dir, reponame) | ||
if not osp.isdir(checkout_dir): | ||
command = ['git', 'clone', '-q', url, '-b', branch, checkout_dir] | ||
_logger.info('Calling %s', ' '.join(command)) | ||
subprocess.check_call(command) | ||
return checkout_dir | ||
|
||
|
||
def clone_repos(checkout_path, repo_path, deps_name='oca_dependencies.txt'): | ||
"""Clone all repos to a give directory all repos in a dependency file""" | ||
deps_path = osp.join(repo_path, deps_name) | ||
if osp.isdir(repo_path) and osp.isfile(deps_path): | ||
deps = parse_depfile(deps_path) or [] | ||
def run_shell(command): | ||
_logger.info('Calling %s', ' '.join(command)) | ||
return subprocess.check_call(command) | ||
|
||
|
||
def git_clone(checkout_path, reponame, url, branch): | ||
checkout_path = osp.join(checkout_path, reponame) | ||
if not osp.isdir(checkout_path): | ||
run_shell(['git', 'clone', '-q', url, '-b', branch, checkout_path]) | ||
return checkout_path | ||
|
||
|
||
def git_merge(checkout_path, reponame, url, branch): | ||
if osp.isdir(checkout_path): | ||
run_shell( | ||
['git', 'config', '--global', | ||
'user.email', '[email protected]']) | ||
run_shell( | ||
['git', 'config', '--global', | ||
'user.name', 'OCA Bot']) | ||
run_shell( | ||
['git', '-C', checkout_path, 'fetch', url, branch]) | ||
run_shell( | ||
['git', '-C', checkout_path, 'merge', '--no-edit', | ||
'-X', 'ours', 'FETCH_HEAD']) | ||
return checkout_path | ||
|
||
|
||
def clone_repos(method, deps_path, deps_name, target_path): | ||
#, git_command, repo_path=None, | ||
# deps_name='oca_dependencies.txt'): | ||
"""Recursively install all dependency repositories | ||
method: function retrieving the repository | ||
deps_path: path where the dependency file is | ||
deps_name: name of the dependency file | ||
target_path: repository destination path | ||
""" | ||
deps_file_path = osp.join(deps_path, deps_name) | ||
if osp.isfile(deps_file_path): | ||
deps = parse_depfile(deps_file_path) or [] | ||
for dep_name, url, branch in deps: | ||
if dep_name not in os.listdir(checkout_path): | ||
_logger.info('Processing %s', dep_name) | ||
checkout_dir = git_checkout( | ||
checkout_path, dep_name, url, branch) | ||
clone_repos(deps_checkout_dir, checkout_dir) | ||
_logger.info('Processing %s', dep_name) | ||
checkout_path = method( | ||
target_path, dep_name, url, branch) | ||
if checkout_path and checkout_path != target_path: | ||
# Only drill down if checkout was on another path | ||
clone_repos( | ||
method, checkout_path, deps_name, target_path) | ||
|
||
|
||
def install_requirements(parent_path): | ||
|
@@ -93,7 +122,10 @@ def install_requirements(parent_path): | |
|
||
|
||
def run(deps_checkout_dir, build_dir): | ||
clone_repos(deps_checkout_dir, build_dir) | ||
clone_repos( | ||
git_merge, build_dir, 'oca_modules.txt', build_dir) | ||
clone_repos( | ||
git_clone, build_dir, 'oca_dependencies.txt', deps_checkout_dir) | ||
install_requirements(deps_checkout_dir) | ||
install_requirements(build_dir) | ||
|
||
|