packit / dist-git-to-source-git

Converting dist-git to source-git
MIT License
4 stars 9 forks source link

[source-git update] git cherry-pick fails due to staged changes #103

Closed jpopelka closed 3 years ago

jpopelka commented 3 years ago
$ cd rpms; git clone https://git.centos.org/rpms/apr.git
$ cd ../source-git; git clone ssh://git@git.stg.centos.org/source-git/apr.git
$ cd ..; CONTAINER_CMD="dist2src -v convert rpms/apr:c8s source-git/apr:c8" make run
docker run \
    -ti --rm \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/dist2src:/usr/local/lib/python3.6/site-packages/dist2src:Z \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/packitpatch:/usr/bin/packitpatch:Z \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/macros.packit:/usr/lib/rpm/macros.d/macros.packit:Z \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/tests:/tests:Z \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/rpms:/workdir/rpms:Z \
    -v /home/jpopelka/git/packit/dist-git-to-source-git/source-git:/workdir/source-git:Z \
    -u 1000 \
     \
    dist2src dist2src -v convert rpms/apr:c8s source-git/apr:c8
convert(origin='rpms/apr:c8s', dest='source-git/apr:c8')
Running command get_sources.sh in /workdir/rpms/apr
rpmbuild stderr = + umask 022
+ cd /workdir/rpms/apr/BUILD
+ cd /workdir/rpms/apr/BUILD
+ rm -rf apr-1.6.3
+ /usr/bin/bzip2 -dc /workdir/rpms/apr/SOURCES/apr-1.6.3.tar.bz2
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd apr-1.6.3
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ /usr/bin/git init
+ /usr/bin/git add -f .
+ /usr/bin/git commit -q --allow-empty -a -m 'apr-1.6.3 base'
+ echo 'Patch #1 (apr-1.6.3-r1834495.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .r1834495 --fuzz=0
+ echo 'Patch #2 (apr-1.2.2-locktimeout.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .locktimeout --fuzz=0
+ echo 'Patch #3 (apr-1.2.2-libdir.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .libdir --fuzz=0
+ echo 'Patch #4 (apr-1.2.7-pkgconf.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .pkgconf --fuzz=0
+ echo 'Patch #5 (apr-rh1539844.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .rh1539844 --fuzz=0
+ echo 'Patch #6 (apr-1.4.8-deepbind.patch):'
+ /usr/bin/packitpatch '%{1}' '%{2}' --fuzz=0 --no-backup-if-mismatch --no-backup-if-mismatch -p1 -b --suffix .deepbind --fuzz=0
+ exit 0

The repo is not dirty, nothing to commit.
Fetch the dist-git %prep branch to source-git branch updates.
Traceback (most recent call last):
  File "/usr/local/bin/dist2src", line 33, in <module>
    sys.exit(load_entry_point('dist-git-to-source-git==0.1.dev218+g8cf46c8.d20201019', 'console_scripts', 'dist2src')())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/dist2src/cli.py", line 83, in wrapper
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/dist2src/cli.py", line 226, in convert
    d2s.convert(origin_branch, dest_branch)
  File "/usr/local/lib/python3.6/site-packages/dist2src/core.py", line 391, in convert
    from_branch=TEMP_SG_BRANCH, to_branch=dest_branch, theirs=update
  File "/usr/local/lib/python3.6/site-packages/dist2src/core.py", line 140, in cherry_pick_base
    self.repo.git.cherry_pick(f"{from_branch}~{num_commits - 1}", **git_options)
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 542, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 1005, in _call_process
    return self.execute(call, **exec_kwargs)
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 822, in execute
    raise GitCommandError(command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git cherry-pick updates~6
  stderr: 'error: your local changes would be overwritten by cherry-pick.
hint: commit your changes or stash them to proceed.
fatal: cherry-pick failed'
make: *** [Makefile:41: run] Error 1
TomasTomecek commented 3 years ago

I'm gonna start by creating a test case for this.

TomasTomecek commented 3 years ago

I'd love to point out that we should create a new branch and not update existing c8 source-git branch with content from c8s

jpopelka commented 3 years ago

Do you mean that I should create c8s branch or that I should create some c8-updated branch or what?

Ok, let's take an easier example, acl package has only c8 branch in dist-git as well as in source-git. If I'm told to regenerate the source-git package how should I do it?

jpopelka commented 3 years ago

I'm gonna start by creating a test case for this.

Do you have any work-around for me meanwhile? (because I'm seeing it every time)

lachmanfrantisek commented 3 years ago

I would say you should use CONTAINER_CMD="dist2src -v convert rpms/acl:c8 source-git/acl:c8" make run

See this example update on rpm. It builds the new source-git changes on the top of the c8s branch, create imports/c8s/rpm-4.14.3-4.el8 branch and lastly move the c8s to the HEAD of that imports branch.

If there is a problem with that, we should fix it.

lachmanfrantisek commented 3 years ago

I'd love to point out that we should create a new branch and not update existing c8 source-git branch with content from c8s

OK, if we don't want to move the old branch, we should have to make optional the last step (moving the HEAD of the branch) that I described in the last comment.

TomasTomecek commented 3 years ago

sorry, missed these comments, reading just now

the guidance I'd love to give is keep things in the same structure as they are in dist-git right now - when we update repos, we should always update the same branches in source-git, so it should always be:

$ dist2src convert dist-git:branch source-git:branch

we should not move changes between c8 and c8s

luckily, the update mechanism "reverts" all previous changes so we can always recover if something bad happens, that's awesome!

does this help?