GithubHelp home page GithubHelp logo

acsone / git-aggregator Goto Github PK

View Code? Open in Web Editor NEW
91.0 18.0 54.0 168 KB

Manage the aggregation of git branches from different remotes to build a consolidated one.

License: GNU Affero General Public License v3.0

Python 100.00%

git-aggregator's Introduction

License: AGPL-3 pre-commit.ci status

https://img.shields.io/pypi/pyversions/git-aggregator

git-aggregator

Manage the aggregation of git branches from different remotes to build a consolidated one.

Configuration file

Create a repos.yaml or repos.yml file:

./product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
        - oca refs/pull/105/head
        - oca refs/pull/106/head

./connector-interfaces:
    remotes:
        oca:  https://github.com/OCA/connector-interfaces.git
        acsone:  https://github.com/acsone/connector-interfaces.git
    merges:
        - oca 6054de2c4e669f85cec380da90d746061967dc83
        - acsone 8.0-connector_flow
        - acsone 80_connector_flow_ir_cron_able-lmi
        - acsone 8.0_connector_flow_improve_eval_config
    target: acsone aggregated_branch_name
    fetch_all:
        - oca

Environment variables inside of this file will be expanded if the proper option is selected.

All the merges are combined into a single branch. By default this branch is called _git_aggregated but another name may be given in the target section.

Fetching only required branches

If any of your merges refer to a specific commit, you will probably need to fetch all remotes from the corresponding remote or use any other strategy to get that fetch working, but we recommend to simply add this like in the example above:

fetch_all:
    - oca
    - other-remote

You can specify that you want to fetch all references from all remotes you have defined with:

fetch_all: true

Shallow repositories

To save big amounts of bandwidth and disk space, you can use shallow clones. These download only a restricted amount of commits depending on some criteria. Available options are depth, shallow-since and shallow-exclude.

Warning

Available options depend on server and client Git version, be sure to use options available for your environment.

You can use those in the defaults sections to apply them everywhere, or specifying them in the corresponding merges section, for which you must use the dict alternate construction. If you need to disable a default in merges, set it to false:

./odoo:
    defaults:
        depth: 20
    remotes:
        odoo: https://github.com/odoo/odoo.git
        ocb: https://github.com/OCA/OCB.git
        acsone: https://github.com/acsone/odoo.git
    merges:
        -
            remote: ocb
            ref: "9.0"
            depth: 1000
        -
            remote: odoo
            ref: refs/pull/14859/head
    target: acsone 9.0

Remember that you need to fetch at least the common ancestor of all merges for it to succeed.

Triggers

It's also possible to specify a command or a list of shell commands to execute after the aggregation (and before the push). The commands are executed into the aggregated directory.

./product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
    target: acsone aggregated_branch_name
    shell_command_after: echo 'my command'

./connector-interfaces:
    remotes:
        oca:  https://github.com/OCA/connector-interfaces.git
        acsone:  https://github.com/acsone/connector-interfaces.git
    merges:
        - oca 9.0
    target: acsone aggregated_branch_name
    shell_command_after:
        - echo 'a first command'
        - echo 'a second command'

A real life example: applying a patch

./odoo:
    remotes:
        oca: https://github.com/OCA/OCB.git
        acsone: [email protected]/acsone/OCB.git
    merges:
        - oca 9.0
    target: acsone aggregated_branch_name
    shell_command_after:
        - git am "$(git format-patch -1 XXXXXX -o ../patches)"

Command line Usage

Following the example repos.yaml file from above, aggregate your repositories at any time:

$ gitaggregate -c repos.yaml

Expand environment variables inside of the configuration file when loading:

$ gitaggregate -c repos.yaml --expand-env

The variables in the configuration file can be specified in one of the following ways:

  • $VARIABLE
  • ${VARIABLE}

For more information, see the Python's string.Template documentation.

Use additional variables from file while expanding:

$ gitaggregate -c repos.yaml --expand-env --env-file .env

The env file should contain VAR=value lines. Lines starting with # are ignored.

You can also aggregate and automatically push the result to the target, if the target option is configured:

$ gitaggregate -c repos.yaml -p

Only aggregate a specific repository using fnmatch:

$ gitaggregate -c repos.yaml -p -d connector-interfaces

Show github pull requests

gitaggregate has a mechanism to identify merges that correpond to merged or closed Github pull requests.

Such merges are of the form refs/pull/NNN/head where NNN is the pull request number, with a https://github.com or [email protected] remote.

To work around API limitation, you must first generate a Github API token.

$ export GITHUB_TOKEN=...
$ gitaggregate -c repos.yaml show-all-prs
$ gitaggregate -c repos.yaml show-closed-prs

Changes

4.0 (2023-07-22)

  • [BREAKING] drop support for other configuration file formats than yaml
  • Ensure git pull is always done in fast-forward mode
  • Drop support for python 3.6, test with python 3.11, stop testing with pypy

3.0.1 (2022-09-21)

  • Fix git clone issue with git < 2.17

3.0.0 (2022-09-20)

  • When updating remotes the log message now states Updating remote instead of Remote remote
  • Add --no-color option to disable colored output
  • Use git clone --filter=blob:none + fetch strategy to improve performance and benefit from git-autoshare if installed

2.1 (August 26, 2021)

2.0 (August 17, 2021)

  • Drop support for python < 3.6
  • Do not exit with success on KeyboardInterrupt
  • Make target optional.

1.8.1 (August 28, 2020)

  • Support environment variables in the configuration file.

1.7.1 (September 30, 2019)

  • If an error happens, log in which repo it happens. Helpful when running in parallel.

1.7.0 (August 14, 2019)

  • Fix a bug in --show-all-prs, which was printing a wrong PR URL.
  • Display PR labels too in --show-all-prs.

1.6.0 (March 04, 2019)

  • Add --show-all-prs command to list all GitHub pull requests used in merge sections.

1.5.0 (December 07, 2018)

  • Add --force. If set, dirty repositories will fail to aggregate.

1.4.0 (September 13, 2018)

  • Add --jobs option for multi-process operation.

1.3.0 (August 21, 2018)

  • Improve configuration file parsing by mimicing Kaptan's behavior of resolving handler by extension (#22)

1.2.1 (July, 12, 2018)

  • show-closed-prs now displays merge status
  • some documentation improvements

1.2.0 (May, 17, 2017)

  • support .yml config file extension
  • add a show-closed-prs command to display github pull requests that are not open anymore; github pull requests must be referenced as refs/pull/NNN/head in the merges section

1.1.0 (Feb, 01, 2017)

  • Use setuptools_scm for the release process (#10)
  • Expand env vars in config. (#8)
  • Shallow repositories. (#7)
  • Fetch only required remotes. (#6)
  • Display readable error if config file not found. (#2)

1.0.0 (Jan, 19, 2016)

  • First release

Credits

Author

Contributors

Maintainer

ACSONE SA/NV

This project is maintained by ACSONE SA/NV.

git-aggregator's People

Contributors

alexaubin avatar ap-wtioit avatar hparfr avatar huguesdk avatar janverb avatar joao-p-marques avatar lasley avatar lmignon avatar p-tombez avatar sbidoul avatar simahawk avatar thomaspaulb avatar yajo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-aggregator's Issues

Installing / Using git-aggregator with python3.10

During testing running doodba with python3.10 we discovered the following issues with git-aggregator and python3.10.

I wanted to discuss this here as i'm guessing that with Odoo 17.0 we would need to run python3.10 in doodba and this seems like it's going to maybe block us.

Do you have the time to fix this until the release of Odoo 17.0 or do we need to prepare a fix / fork ourselves? (With not having the best track record of getting changes needed for doodba into git-aggregator)

Not installable when using the recommended PyYAML:

docker run --rm python:3.10 pip install git-aggregator
Collecting git-aggregator
  Downloading git_aggregator-3.0.1-py3-none-any.whl (30 kB)
Collecting kaptan
  Downloading kaptan-0.5.12.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting argcomplete
  Downloading argcomplete-3.1.1-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.5/41.5 kB 4.4 MB/s eta 0:00:00
Collecting colorama
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 5.4 MB/s eta 0:00:00
Collecting PyYAML<6,>=3.13
  Downloading PyYAML-5.4.1.tar.gz (175 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.1/175.1 kB 6.9 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [62 lines of output]
      /tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!
      
              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.
      
              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.
      
              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************
      
      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running egg_info
      writing lib3/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib3/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 271, in <module>
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 314, in run
          self.find_sources()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 322, in find_sources
          mm.run()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 551, in run
          self.add_defaults()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
          sdist.add_defaults(self)
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/command/sdist.py", line 104, in add_defaults
          super().add_defaults()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
        File "<string>", line 201, in get_source_files
        File "/tmp/pip-build-env-dycfm1vz/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 23.0.1 -> 23.2
[notice] To update, run: pip install --upgrade pip

Kaptan dependency also is not compatible with python3.10

docker run --rm python:3.10 bash -c 'pip install git-aggregator PyYAML==6.0.1 && gitaggregate'
Collecting git-aggregator
  Downloading git_aggregator-3.0.1-py3-none-any.whl (30 kB)
Collecting PyYAML==6.0.1
  Downloading PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (705 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 705.5/705.5 kB 22.0 MB/s eta 0:00:00
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 22.1 MB/s eta 0:00:00
Collecting argcomplete
  Downloading argcomplete-3.1.1-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.5/41.5 kB 17.8 MB/s eta 0:00:00
Collecting kaptan
  Downloading kaptan-0.5.12.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting colorama
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting kaptan
  Downloading kaptan-0.5.11.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Downloading kaptan-0.5.10.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Downloading kaptan-0.5.9.tar.gz (8.4 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Downloading kaptan-0.5.8.tar.gz (7.1 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (201 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 201.8/201.8 kB 10.0 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 38.3 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.0.3-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.6/123.6 kB 45.7 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 25.7 MB/s eta 0:00:00
Building wheels for collected packages: kaptan
  Building wheel for kaptan (setup.py): started
  Building wheel for kaptan (setup.py): finished with status 'done'
  Created wheel for kaptan: filename=kaptan-0.5.8-py3-none-any.whl size=7881 sha256=89258461ec2a2ceccc1203aabe418fedcea810951feae227dc8c49b836193264
  Stored in directory: /root/.cache/pip/wheels/7e/4a/d6/8ca564e693017aeedb1d99cb2a027a423d1064acc243769b22
Successfully built kaptan
Installing collected packages: urllib3, PyYAML, idna, colorama, charset-normalizer, certifi, argcomplete, requests, kaptan, git-aggregator
Successfully installed PyYAML-6.0.1 argcomplete-3.1.1 certifi-2023.5.7 charset-normalizer-3.2.0 colorama-0.4.6 git-aggregator-3.0.1 idna-3.4 kaptan-0.5.8 requests-2.31.0 urllib3-2.0.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.2
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/local/bin/gitaggregate", line 5, in <module>
    from git_aggregator.main import main
  File "/usr/local/lib/python3.10/site-packages/git_aggregator/main.py", line 23, in <module>
    from .config import load_config
  File "/usr/local/lib/python3.10/site-packages/git_aggregator/config.py", line 9, in <module>
    import kaptan
  File "/usr/local/lib/python3.10/site-packages/kaptan/__init__.py", line 15, in <module>
    from collections import Mapping, Sequence
ImportError: cannot import name 'Mapping' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)

[RFC] new sub command "show-diff" or "show-status"

Hi all,

I use a lot git-aggregator locally, with a lot of repositories. Sometime I forgot a pending work in a repository, and before gitaggregate, i'd like to be sure all repo are "clean", and doens't have unadded / uncommited work.

For that purpose, I'd like to implement the following command
gitaggregate -c repos.yml show-status

This command will scan each repository, and display the status (git status) of repos. (or something equivalent)

@sbidoul (+other git-aggregator developpers) : could you say me if this feature could be accepted in this project ?

kind regards.

Merge PR not working ?

Hello,

I am trying this

./odoo:
defaults:
# Shallow repositories ($DEPTH_DEFAULT=1) are faster & thinner
# You may need a bigger depth when merging PRs (use $DEPTH_MERGE
# for a sane value of 100 commits)
depth: $DEPTH_MERGE
remotes:
odoo: https://github.com/odoo/odoo.git
target: odoo $ODOO_VERSION
merges:
- odoo $ODOO_VERSION
- odoo refs/pull/80570/head

and it does not work, I got a

fatal: refusing to merge unrelated histories

But this one is working,

./odoo:
defaults:
# Shallow repositories ($DEPTH_DEFAULT=1) are faster & thinner
# You may need a bigger depth when merging PRs (use $DEPTH_MERGE
# for a sane value of 100 commits)
depth: $DEPTH_MERGE
remotes:
odoo: https://github.com/odoo/odoo.git
target: odoo $ODOO_VERSION
merges:
- odoo $ODOO_VERSION
# - odoo refs/pull/80570/head
# Example of a merge of the PR with the number
# - oca refs/pull//head
shell_command_after:
- git fetch odoo 6d53dd12fbd4826f0d929e12e23119d5ac76e0a1 --depth 100
- git cherry-pick 6d53dd12fbd4826f0d929e12e23119d5ac76e0a1 # refs/pull/80570/head

I could think it's related to fetching, but I cannot find a work around.

Thanks,

Jérôme

origin should be equal to target remote

When using pip install -e then pip freeze, it seems pip uses the origin remote in the frozen requirements.

So it seems it would be better to have origin point to the target remote after the aggregation.

Not possible to get specific commit

I'm using latest gitaggregator 1.8.1.

I'm running gitaggregate --expand-env --config repos.yaml --jobs 4 aggregate

I have this in my config file:

ICTSTUDIO/odoo-extra-addons:
  defaults:
    depth: 100
  remotes:
    origin: https://github.com/ICTSTUDIO/odoo-extra-addons.git
  target: origin 10.0
  merges:
    - origin 6105fb108c2fa27fee68bab7a5fb9af95e4166e
  fetch_all: true

I'm getting:

Traceback (most recent call last):
File "/data/buildout/freshfilter/.venv/lib/python2.7/site-packages/git_aggregator/main.py", line 219, in aggregate_repo
repo.aggregate()
File "/data/buildout/freshfilter/.venv/lib/python2.7/site-packages/git_aggregator/repo.py", line 191, in aggregate
self._merge(merge)
File "/data/buildout/freshfilter/.venv/lib/python2.7/site-packages/git_aggregator/repo.py", line 270, in _merge
self.log_call(cmd, cwd=self.cwd)
File "/data/buildout/freshfilter/.venv/lib/python2.7/site-packages/git_aggregator/repo.py", line 160, in log_call
ret = callwith(cmd, **kw)
File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '(u'git', u'pull', u'--no-edit', u'--quiet', u'--depth', '100', 'origin', '6105fb108c2fa27fee68bab7a5fb9af95e4166e')' returned non-zero exit status 1

using local cache

I would like to suggest to add a new option, say --cache-dir and when it's presented use one of following options to initialise repository:

  • use git clone --reference
  • use git worktree add command instead of git init -- looks as a better option as it doesn't require to change much in the scripts

This would decrease network and storage costs on working with big repositories like odoo

[Question] How to use an env variable for pr number?

I have this repo in the config file:

./odoo-staging:
  defaults:
    depth: $DEPTH_MERGE
  remotes:
    main: [email protected]:obayit/project.git
  target: main project
  merges:
    - main project
    - main refs/pull/$TEST_PR/head

When I run gitaggregate, I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/gitaggregate", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/main.py", line 176, in main
    run(args)
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/main.py", line 237, in run
    args.config, args.expand_env, args.env_file, args.force)
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/config.py", line 159, in load_config
    config = config.substitute(environment)
  File "/usr/local/lib/python3.5/string.py", line 129, in substitute
    return self.pattern.sub(convert, self.template)
  File "/usr/local/lib/python3.5/string.py", line 119, in convert
    val = mapping[named]
KeyError: 'TEST_PR'

``fetch`` followed by ``pull`` is inefficient

I noticed while tinkering with gitaggregate 1.6.0 (git version 2.7.4) that it was issuing a fetch followed by pull. As we all know, pull is a shorthand for a fetch followed by a merge. We could think that the second fetch is not so harmful as it won't download anything... but that wrong:

  • the second pull is not garanteed to give the same resut that the first fetch (the target might have changed in between), and this might have some consequence in the code.
  • even in --depth 1 and when the code didn't change, there are still some computation and network exchanges that could be avoided.

Full example:

mkdir /tmp/gita -p &&
cd /tmp/gita &&
cat <<EOF > repos.yaml
./foo:
    defaults:
        depth: 1
    remotes:
        r1: file:///tmp/gita/r1
    target: r1 agg
    merges:
    - r1 t1
EOF

## making remote git repository 'r1'
mkdir -p r1 && cd r1
git init . &&
touch a &&
git add a &&
git commit -am "first commit" &&
git tag t1 &&
cd ..

gitaggregate -c repos.yaml --log-level DEBUG

would output

(D) [17:18:29] git_aggregator.main  foo  main.aggregate_repo():198 <git_aggregator.repo.Repo object at 0x7f2e0fe29d68>
(I) [17:18:29] git_aggregator.repo  foo  repo.aggregate():169 Start aggregation of /tmp/gita/foo
(I) [17:18:29] git_aggregator.repo  foo  repo.init_repository():192 Init empty git repository in /tmp/gita/foo
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'init', '/tmp/gita/foo']
Initialized empty Git repository in /tmp/gita/foo/.git/
(I) [17:18:29] git_aggregator.repo  foo  repo._switch_to_branch():247 Switch to branch agg
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'checkout', '-B', 'agg']
Switched to a new branch 'agg'
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', '-v']
(I) [17:18:29] git_aggregator.repo  foo  repo._set_remote():298 Adding remote r1 <file:///tmp/gita/r1>
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', 'add', 'r1', 'file:///tmp/gita/r1']
(I) [17:18:29] git_aggregator.repo  foo  repo.fetch():197 Fetching required remotes
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'fetch', '--depth', '1', 'r1', 't1')
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From file:///tmp/gita/r1
 * tag               t1         -> FETCH_HEAD
(I) [17:18:29] git_aggregator.repo  foo  repo._merge():256 Pull r1, t1
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'pull', '--no-edit', '--depth', '1', 'r1', 't1')
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From file:///tmp/gita/r1
 * tag               t1         -> FETCH_HEAD
(I) [17:18:29] git_aggregator.repo  foo  repo._execute_shell_command_after():251 Execute shell after commands
(I) [17:18:29] git_aggregator.repo  foo  repo.aggregate():189 End aggregation of /tmp/gita/foo

Notice the 2 full outputs with obvious computation done twice.

I noted that the second output seems smaller (and quicker?) if depth: 1 is in defaults. And no fetch_all is activated.

I have a PR solving this issue coming soon.

need restart after installing library

hi all,

I installed recently on new fresh computers (ubuntu 18.04) this library. via pip install git-aggregator

Each time, I have to restart the system to have the gitaggregate command available.

do you have the same issue ?

does it come of pypi or from this library configuration ?

thanks !

[RFC] Include pre-commit install in git-aggregator (OCA context but not only)

Hi all,

git-aggregator is using git clone command to recover all the repository.
Since OCA is introducing pre-commit feature, I was thinking to automatically call the command pre-commit install after cloning a repository by git-aggregator. (we should check if pre-commit is installed / or add a new dependency).

(Ref : https://odoo-community.org/blog/the-oca-blog-1/post/black-isort-pre-commit-97)
Does it make sense for you ?

kind regards.

Confusing logs in parallel mode

When using git-aggregator with --jobs to download repos in parallel, the logs don't indicate in which repo is there an error.

See this example:

(INFO) [07:30:08] git_aggregator.repo  account-invoicing   Start aggregation of /opt/odoo/custom/src/account-invoicing
(INFO) [07:30:08] git_aggregator.repo  e-commerce   Start aggregation of /opt/odoo/custom/src/e-commerce
(INFO) [07:30:08] git_aggregator.repo  account-invoicing   Switch to branch 11.0
(INFO) [07:30:08] git_aggregator.repo  odoo   Start aggregation of /opt/odoo/custom/src/odoo
(INFO) [07:30:08] git_aggregator.repo  e-commerce   Switch to branch 11.0
(INFO) [07:30:08] git_aggregator.repo  odoo   Switch to branch 11.0
website_sale_attribute_filter_category/i18n/website_sale_attribute_filter_category.pot: needs merge
error: you need to resolve your current index first
Reset branch '11.0'
(INFO) [07:30:08] git_aggregator.repo  account-invoicing   Remote already exists oca <https://github.com/OCA/account-invoicing.git>
(INFO) [07:30:08] git_aggregator.repo  account-invoicing   Fetching required remotes
Reset branch '11.0'
(INFO) [07:30:09] git_aggregator.repo  odoo   Remote already exists odoo <https://github.com/odoo/odoo.git>
(INFO) [07:30:09] git_aggregator.repo  odoo   Remote already exists ocb <https://github.com/OCA/OCB.git>
(INFO) [07:30:09] git_aggregator.repo  odoo   Remote already exists tecnativa <https://github.com/Tecnativa/odoo.git>
(INFO) [07:30:09] git_aggregator.repo  odoo   Remote already exists openupgrade <https://github.com/OCA/OpenUpgrade.git>
(INFO) [07:30:09] git_aggregator.repo  odoo   Fetching required remotes
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
From https://github.com/OCA/account-invoicing
 * branch            11.0       -> FETCH_HEAD
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
From https://github.com/OCA/OCB
 * branch                11.0       -> FETCH_HEAD
(INFO) [07:30:11] git_aggregator.repo  odoo   Checking repo status
(INFO) [07:30:11] git_aggregator.repo  odoo   Reset branch to ocb 11.0
remote: Enumerating objects: 805, done.
remote: Counting objects: 100% (559/559), done.
remote: Compressing objects: 100% (193/193), done.
remote: Total 337 (delta 237), reused 240 (delta 140), pack-reused 0
Receiving objects: 100% (337/337), 63.98 KiB | 0 bytes/s, done.
(INFO) [07:30:13] git_aggregator.repo  odoo   Execute shell after commands
(INFO) [07:30:13] git_aggregator.repo  odoo   End aggregation of /opt/odoo/custom/src/odoo
Resolving deltas: 100% (237/237), completed with 53 local objects.
From https://github.com/OCA/account-invoicing
 * branch            refs/pull/415/head -> FETCH_HEAD
(INFO) [07:30:13] git_aggregator.repo  account-invoicing   Checking repo status
(INFO) [07:30:13] git_aggregator.repo  account-invoicing   Reset branch to oca 11.0
(INFO) [07:30:14] git_aggregator.repo  account-invoicing   Pull oca, refs/pull/415/head
(INFO) [07:30:15] git_aggregator.repo  account-invoicing   Execute shell after commands
(INFO) [07:30:15] git_aggregator.repo  account-invoicing   End aggregation of /opt/odoo/custom/src/account-invoicing
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/main.py", line 204, in aggregate_repo
    repo.aggregate()
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/repo.py", line 176, in aggregate
    self._switch_to_branch(self.target['branch'])
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/repo.py", line 248, in _switch_to_branch
    self.log_call(['git', 'checkout', '-B', branch_name], cwd=self.cwd)
  File "/usr/local/lib/python3.5/site-packages/git_aggregator/repo.py", line 159, in log_call
    ret = callwith(cmd, **kw)
  File "/usr/local/lib/python3.5/subprocess.py", line 271, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'checkout', '-B', '11.0']' returned non-zero exit status 1
Traceback (most recent call last):
  File "/usr/local/bin/autoaggregate", line 129, in <module>
    aggregate(REPOS_YAML)
  File "/usr/local/bin/autoaggregate", line 43, in aggregate
    stdout=sys.stdout,
  File "/usr/local/lib/python3.5/subprocess.py", line 271, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gitaggregate', '--expand-env', '--config', '/opt/odoo/custom/src/repos.yaml', '--jobs', '8']' returned non-zero exit status 1

So, which repo failed above? 😵

cc @cubells

git-aggregator 3.0.0 no longer works with git from debian stretch

In doodba debian stretch is used for Odoo Version 11.0 and 12.0.

The git version in this images has no --filter=blob:none option for git clone:
docker run --rm tecnativa/doodba:11.0 git --version: git version 2.11.0

docker run --rm tecnativa/doodba:11.0 git clone --filter=blob:none http://example.com/:

error: unknown option `filter=blob:none'
usage: git clone [<options>] [--] <repo> [<dir>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    --mirror              create a mirror repository (implies bare)
    -l, --local           to clone from a local repository
    --no-hardlinks        don't use local hardlinks, always copy
    -s, --shared          setup as shared repository
    --recursive           initialize submodules in the clone
    --recurse-submodules  initialize submodules in the clone
    -j, --jobs <n>        number of submodules cloned in parallel
    --template <template-directory>
                          directory from which templates will be used
    --reference <repo>    reference repository
    --reference-if-able <repo>
                          reference repository
    --dissociate          use --reference only while cloning
    -o, --origin <name>   use <name> instead of 'origin' to track upstream
    -b, --branch <branch>
                          checkout <branch> instead of the remote's HEAD
    -u, --upload-pack <path>
                          path to git-upload-pack on the remote
    --depth <depth>       create a shallow clone of that depth
    --shallow-since <time>
                          create a shallow clone since a specific time
    --shallow-exclude <revision>
                          deepen history of shallow clone by excluding rev
    --single-branch       clone only one branch, HEAD or --branch
    --shallow-submodules  any cloned submodules will be shallow
    --separate-git-dir <gitdir>
                          separate git dir from working tree
    -c, --config <key=value>
                          set config inside the new repository
    -4, --ipv4            use IPv4 addresses only
    -6, --ipv6            use IPv6 addresses only

See also Tecnativa/doodba#523

aggregate option is optional in Python 3 but required in Python 2

This command works in python 3 but fails in python 2:

$ gitaggregate --expand-env --config repos.yaml --log-level INFO --jobs 2
usage: gitaggregate [-h] -c [CONFIG] [-p] [-d [DIRMATCH]]
                    [--log-level [LOG_LEVEL]] [-e] [--env-file ENV_FILE] [-f]
                    [-j JOBS]
                    {aggregate,show-all-prs,show-closed-prs} ...
gitaggregate: error: too few arguments

I have to append aggregate for py2 to work.

RFC: ENV VARS to control default depth or shallow-since options

Hello,

As mentioned in the git-aggregator readme: specifying depth or shallow-since options allows to greatly reduce the bandwidth and disk space. In fact you can avoid a full fetch or Odoo branches (over 5 Gb even for a --single-branch) and get down to 280 Mb or so if you use a fetch with --shalllow-since the date of the Odoo release which is far enough history to merge any patch pull request.

But if you have such a shallow Odoo fetch, your merges will only avoid a full fetch again if you also specify depth or shallow-since in each of your merges. This leads to a more complicated and error prone syntax to detail all these options in your merges. If somebody forgets the option in only one merge, you'll download over 5Gb of Odoo history again in your build...

So I wonder if we could not simply have ENV VARS such as DEFAULT_AGGREGATOR_DEPTH and DEFAULT_AGGREGATOR_SHALLOW_SINCE that would be used by git-aggregator and specially the _fetch_options method to default to these values of no merge option is specified.

What do you think? If you agree I can propose a PR.

Proposal: patches and diffs support

This is one idea that came to my mind. The quick summary is to be able to do things like this:

./odoo:
    defaults:
        depth: 100 # Shallow clone, faster but less git merge ability
    remotes:
        ocb: https://github.com/OCA/OCB.git
        odoo: https://github.com/odoo/odoo.git
        openupgrade: https://github.com/OCA/OpenUpgrade.git
    target: ocb 12.0 # I'm cloning version 12.0
    merges:
        - ocb 12.0
        - odoo 12.0
    # Here comes the meat:
    patches:
        - https://github.com/odoo/odoo/pull/37142.patch
    diffs:
        - https://github.com/odoo/odoo/pull/37187.diff # This is a PR for branch 11.0, merged on branch 12.0!

The effect of these new configuration items would be the same as executing:

# To merge patches:
curl -sSL https://github.com/odoo/odoo/pull/37142.patch | git am -3 --keep-non-patch -

# To merge diffs:
curl -sSL https://github.com/odoo/odoo/pull/37187.diff | patch -fp1
git add .
git commit -m "Merging diff https://github.com/odoo/odoo/pull/37187.diff"

The point of adding patches is maybe not so much important because almost the same you can get with just plain git, and it shares the same limitations. For example, the depth: 100 key will make the git am command fail if the cloned shallow repository doesn't have the parent commit.1

However, adding diffs would enable us to merge patches that don't share parent commits. In this concrete case, I'm applying a patch for branch 11.0 on top of the 12.0 branch, without sharing a parent commit in git history. This enables both a fast repo download and a flexible merging system that doesn't depend on the present branch but only on the present code.


1 For this concrete case, if you open https://github.com/odoo/odoo/pull/37142.patch you'll see the required parent commit is 23c3fb1abce11d3d5b71cf31a3925198b53d1ea9.

@Tecnativa TT19524

merge targets can't be annotated tags

Annotated tags will crash git-aggregate when used as merge targets:
Using git version 2.7.4, and gitaggregate version 1.6.0.

mkdir /tmp/gita -p &&
cd /tmp/gita &&
cat <<EOF > repos.yaml
./foo:
    remotes:
        r1: file:///tmp/gita/r1
    target: r1 agg
    merges:
    - r1 annotated_tag
EOF

## making remote git repository 'r1', with one single commit and an annotated tag
mkdir -p r1 && cd r1
git init . &&
touch a &&
git add a &&
git commit -am "first commit" &&
git tag -am "hop" annotated_tag &&
cd ..

gitaggregate -c repos.yaml --log-level DEBUG

Would output:

(D) [16:53:48] git_aggregator.main  foo  main.aggregate_repo():198 <git_aggregator.repo.Repo object at 0x7fc528db2ba8>
(I) [16:53:48] git_aggregator.repo  foo  repo.aggregate():169 Start aggregation of /tmp/gita/foo
(I) [16:53:48] git_aggregator.repo  foo  repo.init_repository():192 Init empty git repository in /tmp/gita/foo
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'init', '/tmp/gita/foo']
Initialized empty Git repository in /tmp/gita/foo/.git/
(I) [16:53:48] git_aggregator.repo  foo  repo._switch_to_branch():247 Switch to branch agg
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'checkout', '-B', 'agg']
Switched to a new branch 'agg'
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', '-v']
(I) [16:53:48] git_aggregator.repo  foo  repo._set_remote():298 Adding remote r1 <file:///tmp/gita/r1>
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', 'add', 'r1', 'file:///tmp/gita/r1']
(I) [16:53:48] git_aggregator.repo  foo  repo.fetch():197 Fetching required remotes
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'fetch', 'r1', 'annotated_tag')
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From file:///tmp/gita/r1
 * tag               annotated_tag -> FETCH_HEAD
(I) [16:53:48] git_aggregator.repo  foo  repo._merge():256 Pull r1, annotated_tag
(D) [16:53:48] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'pull', '--no-edit', 'r1', 'annotated_tag')
From file:///tmp/gita/r1
 * tag               annotated_tag -> FETCH_HEAD
fatal: update_ref failed for ref 'HEAD': cannot update the ref 'HEAD': Trying to write non-commit object 15f3593b4d0e7198d32e723df7d901b2f9fba96e to branch refs/heads/agg
Traceback (most recent call last):
  File "/home/vaab/lib/python/site-packages/git_aggregator/main.py", line 204, in aggregate_repo
    repo.aggregate()
  File "/home/vaab/lib/python/site-packages/git_aggregator/repo.py", line 187, in aggregate
    self._merge(merge)
  File "/home/vaab/lib/python/site-packages/git_aggregator/repo.py", line 266, in _merge
    self.log_call(cmd, cwd=self.cwd)
  File "/home/vaab/lib/python/site-packages/git_aggregator/repo.py", line 159, in log_call
    ret = callwith(cmd, **kw)
  File "/home/vaab/dev/python/pyenv/versions/3.7.3/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('git', 'pull', '--no-edit', 'r1', 'annotated_tag')' returned non-zero exit status 128.

I've already solved this and will be posting a PR in a few minutes.

aggregate inside a docker

Hello guys,

I am new to git-aggregator and I have some issues that I can't explain:

  • Merges seem to be required. Is that by design? I would like to use the module to pull some repo without applying any merges/updates on it.
  • I have a difference between the behavior on the host and inside my docker.
    My docker is pretty simple, based on odoo:10.0.

Here is the traceback from inside the docker

 ---> d48a929fb012
Step 22/22 : RUN cd /tmp     && gitaggregate -c /tmp/repos.yaml     && mv -f /tmp/third/*/* ${THIRD_PARTY_ADDONS}     && rm /tmp/third
 ---> Running in 31ad195be6a9
(INFO) [18:02:29] git_aggregator.repo  Start aggregation of /tmp/third/l10n-canada
(INFO) [18:02:29] git_aggregator.repo  Init empty git repository in /tmp/third/l10n-canada
Initialized empty Git repository in /tmp/third/l10n-canada/.git/
(INFO) [18:02:29] git_aggregator.repo  Switch to branch 9c1b75a837c0f15e127ee656e871b78db1407505
Switched to a new branch '9c1b75a837c0f15e127ee656e871b78db1407505'
(INFO) [18:02:29] git_aggregator.repo  Adding remote oca <https://github.com/OCA/l10n-canada>
(INFO) [18:02:29] git_aggregator.repo  Adding remote sfl <https://github.com/savoirfairelinux/l10n-canada>
(INFO) [18:02:29] git_aggregator.repo  Fetching required remotes
error: no such remote ref 40176efdbd2acbd4ae70e548af4a077afed11d5d
Traceback (most recent call last):
  File "/usr/local/bin/gitaggregate", line 11, in <module>
    load_entry_point('git-aggregator==1.2.1.dev6+g36a77e5', 'console_scripts', 'gitaggregate')()
  File "/usr/local/lib/python2.7/dist-packages/git_aggregator/main.py", line 131, in main
    run(args)
  File "/usr/local/lib/python2.7/dist-packages/git_aggregator/main.py", line 174, in run
    r.aggregate()
  File "/usr/local/lib/python2.7/dist-packages/git_aggregator/repo.py", line 179, in aggregate
    self.fetch()
  File "/usr/local/lib/python2.7/dist-packages/git_aggregator/repo.py", line 202, in fetch
    self.log_call(cmd, cwd=self.cwd)
  File "/usr/local/lib/python2.7/dist-packages/git_aggregator/repo.py", line 156, in log_call
    ret = callwith(cmd, **kw)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '(u'git', u'fetch', 'sfl', '40176efdbd2acbd4ae70e548af4a077afed11d5d')' returned non-zero exit status 128
ERROR: Service 'odoo' failed to build: The command '/bin/sh -c cd /tmp     && gitaggregate -c /tmp/repos.yaml     && mv -f /tmp/third/*/* ${THIRD_PARTY_ADDONS}     && rm /tmp/third' returned a non-zero code: 1

While it works smoothly on the host:

(gitaggregate) ftc@ftc-XPS-13-9360 ~/p/odoo-aggr> gitaggregate -c ./repos.yaml 
(INFO) [13:02:58] git_aggregator.repo  Start aggregation of /home/ftc/projects/odoo-aggr/third/l10n-canada
(INFO) [13:02:58] git_aggregator.repo  Init empty git repository in /home/ftc/projects/odoo-aggr/third/l10n-canada
Initialized empty Git repository in /home/ftc/projects/odoo-aggr/third/l10n-canada/.git/
(INFO) [13:02:58] git_aggregator.repo  Switch to branch 9c1b75a837c0f15e127ee656e871b78db1407505
Switched to a new branch '9c1b75a837c0f15e127ee656e871b78db1407505'
(INFO) [13:02:58] git_aggregator.repo  Adding remote oca <https://github.com/OCA/l10n-canada>
(INFO) [13:02:58] git_aggregator.repo  Adding remote sfl <https://github.com/savoirfairelinux/l10n-canada>
(INFO) [13:02:58] git_aggregator.repo  Fetching required remotes
remote: Counting objects: 1280, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 1280 (delta 1), reused 0 (delta 0), pack-reused 1278
Receiving objects: 100% (1280/1280), 392.40 KiB | 749.00 KiB/s, done.
Resolving deltas: 100% (834/834), done.
From https://github.com/savoirfairelinux/l10n-canada
 * branch            40176efdbd2acbd4ae70e548af4a077afed11d5d -> FETCH_HEAD
(INFO) [13:02:59] git_aggregator.repo  Pull sfl, 40176efdbd2acbd4ae70e548af4a077afed11d5d
(INFO) [13:02:00] git_aggregator.repo  Execute shell after commands
(INFO) [13:02:00] git_aggregator.repo  End aggregation of /home/ftc/projects/odoo-aggr/third/l10n-canada

repos.yaml:

  remotes:
    oca: https://github.com/OCA/l10n-canada
    sfl: https://github.com/savoirfairelinux/l10n-canada
  merges:
    - sfl 40176efdbd2acbd4ae70e548af4a077afed11d5d
  target: oca 9c1b75a837c0f15e127ee656e871b78db1407505

Do you see anything that should be changed?

Proposal: rebase on primary upstream

An optomized workflow would be in my opinion represented as follows:

...
origin: <url>
upstream: 
  url: <url>
  ref: <ref>
  rebase: <default: true>  # target will be rebased on upstream, first
remotes:
  - name: <name>
    url: <url>
    merge:
       - <ref>
       - <ref>
target: <branchname on local & origin>
...

what is ``target`` and coud it made to be optional ?

In our process, and in the documentation, it was not clear at first what purpose would serve the currently mandatory target option in yaml config file. After doing some tinkering, it seems to me that it actually should be optional, it could maybe be required only for special occasion (thinking of push functionality)... but even then, it seems it would be better moved away.

As we can see in your documentation example, it seems both part of the target the "remote" or the "branch" part are either not used (the remote is only used on push, which is optional), or could be kept as an internal implementation choice or fixed value as it appears to be the branch name where we will merge all merge targets.

I could understand to keep this as an option, but because of its apparent similarity with the format of remotes, which are actually not at all the same, this generates much mis-comprehension. For instance the reference part of target can only be a branch name (whereas reference part of merge supports commits sha1 and tags)... and target's branch anyway will be created (or reseted if existent in the repository) anyway.

For me, to the best of my imperfect knowledge, it seems an improvement to remove this option whenever we don't need it.

It seems it could be called "push-target", and be optional.

What are your thoughts ?

AGPL for a library?

This is more a question than an issue, although it could be an issue...

Why did you choose AGPL for a library? It is suited for web servers...

I'd have chosen GPL, whose section 13 makes it 100% compatible with AGPL, or LGPL.

Great tool, thanks!

pack has unresolved deltas with git-aggregator 3.0.0 and 3.0.1 with git 2.20.1 (debian buster, 10)

not yet reproduced with public commits (will update tomorrow)

when using git-aggregator 3.0.0 or 3.0.1 with git 2.20.1 and performing gitaggregate --expand-env --config .../repo.yaml aggregate:

./odoo:
  defaults:
    depth: $DEPTH_MERGE
  merges:
  - example $ODOO_VERSION
  - example 13.0-patch_branch
  remotes:
    odoo: https://gitlab-ci-token:[email protected]/group_a/odoo.git
    example: https://gitlab-ci-token:[email protected]/group_b/odoo.git
    example-odoo: https://gitlab-ci-token:[email protected]/group_a/odoo.git
  target: example $ODOO_VERSION

with

  • ODOO_VERSION 13.0
  • DEPTH_MERGE 100
    we get the following error:
(INFO) [14:45:42] git_aggregator.repo  odoo   Start aggregation of /tmp/tmppzdk14gj/odoo
(INFO) [14:45:42] git_aggregator.repo  odoo   Cloning git repository https://gitlab-ci-token:[email protected]/group_b/odoo.git in /tmp/tmppzdk14gj/odoo
Cloning into '/tmp/tmppzdk14gj/odoo'...
Checking out files: 100% (25549/25549), done.
(INFO) [14:46:17] git_aggregator.repo  odoo   Switch to branch 13.0
Reset branch '13.0'
(INFO) [14:46:18] git_aggregator.repo  odoo   Adding remote odoo <https://gitlab-ci-token:[email protected]/group_a/odoo.git>
(INFO) [14:46:18] git_aggregator.repo  odoo   Adding remote example <https://gitlab-ci-token:[email protected]/group_b/odoo.git>
Your branch is up to date with 'origin/13.0'.
(INFO) [14:46:18] git_aggregator.repo  odoo   Adding remote example-odoo <https://gitlab-ci-token:[email protected]/group_b/odoo.git>
(INFO) [14:46:18] git_aggregator.repo  odoo   Fetching required remotes
From https://gitlab.example.com/group_b/odoo
 * branch              13.0       -> FETCH_HEAD
 * [new branch]        13.0       -> example/13.0
fatal: pack has 42 unresolved deltas
fatal: index-pack failed
(ERROR) [14:46:26] git_aggregator.repo  odoo   /tmp/tmppzdk14gj/odoo> error calling ('git', 'fetch', '--depth', '100', 'example', '13.0-patch_branch')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/git_aggregator/main.py", line 230, in aggregate_repo
    repo.aggregate()
  File "/usr/local/lib/python3.7/dist-packages/git_aggregator/repo.py", line 183, in aggregate
    self.fetch()
  File "/usr/local/lib/python3.7/dist-packages/git_aggregator/repo.py", line 248, in fetch
    self.log_call(cmd, cwd=self.cwd)
  File "/usr/local/lib/python3.7/dist-packages/git_aggregator/repo.py", line 160, in log_call
    ret = callwith(cmd, **kw)
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('git', 'fetch', '--depth', '100', 'example', '13.0-patch_branch')' returned non-zero exit status 128.

When i increase DEPTH_MERGE to 1000 i get fatal: pack has 228 unresolved deltas and the rest stays the same.

Those errors do not happen if i use git-aggregator 2.1.0 (or my local dev environment with git 2.34.1 + python 3.10).

It does look like it's related to the --filter stuff but i think the root cause is somewhere in git.

git-autoshare never triggered?

Hello @sbidoul. I like both your git-aggregator and git-autoshare tools. However, git-aggregator triggers git init and git fetch but never the git clone command (see https://github.com/acsone/git-aggregator/blob/master/git_aggregator/repo.py ).
So git-autoshare will never get triggered unless you do a git clone of the repo previously before calling git-aggregator.
Woudn't there be a way to trigger git clone/git-autoshare when the repo is empty at least?
What do you think?

Semantic problem

...
merges:
  - depth:  # problem

I understand the depth is principally on the remote, imagine the case where you merge different refs from the same remote. What happens if depth=1?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.