Skip to content

Commit 3016b73

Browse files
committed
Added --git-single-branch and git-depth-1 opts to odoo-helper fetch cmd
1 parent 1ad3c3f commit 3016b73

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Unreleased
44

5+
### Added
6+
7+
- Added new options to `fetch` command:
8+
- `--git-single-branch` could be used to clone repos with single branch options
9+
- `--git-depth-1` could be used to clone repos with option `--depth=1`
10+
11+
512
### Fixes
613

714
- `flake8-colors` not needed anymore, as flake8 support color output byt default.

lib/fetch.bash

+31-9
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ function fetch_clone_repo_git {
274274
fi
275275

276276
# TODO: Add support for cloning repos with depth=1
277+
if [ -n "$ODOO_HELPER_FETCH_GIT_DEPTH_1" ]; then
278+
git_clone_opt="$git_clone_opt --depth=1";
279+
fi
277280

278281
[ -z "$VERBOSE" ] && git_clone_opt="$git_clone_opt -q "
279282
git_cmd="git $extra_git_opt clone --recurse-submodules $git_clone_opt $repo_url $repo_dest";
@@ -401,22 +404,35 @@ function fetch_module {
401404
$SCRIPT_NAME fetch --requirements <requirements file>
402405
403406
Options:
404-
-r|--repo <repo> - git repository to get module from
405-
--github <user/repo> - allows to specify repository located on github in short format
406-
--oca <repo name> - allows to specify Odoo Comunity Association module in simpler format
407-
--odoo-app <app_name> - [experimental] fetch module from Odoo Apps Market.
407+
-r|--repo <repo> - Git repository to get module from
408+
--github <user/repo> - Allows to specify repository located on github in short format
409+
--oca <repo name> - Allows to specify Odoo Comunity Association module in simpler format
410+
--git-single-branch - Clone git repositories with '--single-branch' options.
411+
This could make clonning faster and use less space.
412+
Suitable for server installations.
413+
--git-depth-1 - Clone git repositories with '--depth=1' option.
414+
This option could signifiantly reduce size of large git
415+
repositories and download speed. But as drawback, it
416+
does not suit well for development, because it could be difficult
417+
to push changes back to repository.
418+
But, it should be helpful in case of using docker to reduce
419+
size of resulting docker image and faster build.
420+
--odoo-app <app_name> - [experimental] Fetch module from Odoo Apps Market.
408421
Works only for free modules.
409-
-m|--module <module> - module name to be fetched from repository
410-
-n|--name <repo name> - repository name. this name is used for directory to clone repository in.
422+
-m|--module <module> - Module name to be fetched from repository
423+
-n|--name <repo name> - Repository name. this name is used for directory to clone repository in.
411424
Usualy not required
412-
-b|--branch <branch> - name fo repository branch to clone
413-
--requirements <file> - path to requirements file to fetch required modules
425+
-b|--branch <branch> - Name fo repository branch to clone
426+
--requirements <file> - Path to requirements file to fetch required modules
414427
NOTE: requirements file must end with newline.
415428
416429
Configuration via environment variables:
417430
- ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH - if set then odoo-helper
418431
will use --single-branch
419-
option to clone repo
432+
option to clone repositories
433+
- ODOO_HELPER_FETCH_GIT_DEPTH_1 - if set, the odoo-helper
434+
will user --depth=1 option
435+
to clone repositories
420436
- ODOO_HELPER_FETCH_PIP_AUTO_REQUIREMENTS - if set, then odoo-helper
421437
will process requirements.auto.txt
422438
file in repositories/modules
@@ -490,6 +506,12 @@ function fetch_module {
490506
REPO_BRANCH=${REPO_BRANCH:-${ODOO_VERSION:-$ODOO_BRANCH}};
491507
shift;
492508
;;
509+
--git-single-branch)
510+
ODOO_HELPER_FETCH_GIT_SINGLE_BRANCH=1;
511+
;;
512+
--git-depth-1)
513+
ODOO_HELPER_FETCH_GIT_DEPTH_1=1;
514+
;;
493515
--odoo-app)
494516
fetch_download_odoo_app "$2";
495517
return;

tests/test.bash

+4-4
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ odoo-helper install js-tools;
360360

361361

362362
# Install oca/partner-contact addons
363-
odoo-helper fetch --oca partner-contact;
363+
odoo-helper fetch --git-single-branch --oca partner-contact;
364364

365365
# Regenerate Ukrainian translations for partner_firstname addons
366366
odoo-helper tr regenerate --lang uk_UA --file uk_UA partner_firstname;
@@ -397,7 +397,7 @@ odoo-helper-addons-update base
397397

398398
# Fetch OCA account-financial-reporting, which seems to have
399399
# complicated enough dependencies for this test
400-
odoo-helper fetch --oca account-financial-reporting
400+
odoo-helper fetch --git-single-branch --oca account-financial-reporting
401401

402402
# Clone repository explicitly and link it
403403
(cd repositories && \
@@ -412,7 +412,7 @@ odoo-helper addons update-list
412412

413413
# Generate requirements and fetch them again
414414
odoo-helper addons generate-requirements > /tmp/odoo-requirements.txt
415-
odoo-helper fetch --requirements /tmp/odoo-requirements.txt
415+
odoo-helper fetch --git-single-branch --requirements /tmp/odoo-requirements.txt
416416

417417
# Try to reinstall virtualenv and run server
418418
odoo-helper install reinstall-venv;
@@ -524,7 +524,7 @@ Fetch OCA/web repo
524524
==================
525525
${NC}"
526526
# Fetch oca/web passing only repo url and branch to fetch command
527-
odoo-helper fetch https://github.com/oca/web --branch 11.0;
527+
odoo-helper fetch https://github.com/oca/web --branch 11.0 --git-single-branch --git-depth-1;
528528

529529
echo -e "${YELLOWC}
530530
============================================

0 commit comments

Comments
 (0)