This module uses gbp and upstream git repository.

As of version 1.041, =pristine-tar= branch is no longer updated.

The instructions of this file assume that the branches are:
- master :: Debian work
- upstream :: upstream branch from github

To work on this package, please run:

#+begin_src shell
  git clone https://salsa.debian.org/perl-team/modules/packages/cme.git
  git remote add upstreamvcs https://github.com/dod38fr/cme-perl.git
#+end_src

To update this package, first import the changes from upstream:
#+begin_src shell :dir .. :exports code :results verbatim
git fetch --all
#+end_src

#+RESULTS:
: Récupération de origin
: Récupération de upstreamvcs

Find the latest version:
#+NAME: version
#+begin_src shell :dir .. :exports code :results verbatim
VERSION=$(git describe --tags $(git rev-list '--tags=v*' --max-count=1) | sed 's/^v//')
echo -n $VERSION
#+end_src

#+RESULTS: version
: 1.041

Update upstream branch:
#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  git checkout upstream
  git merge v$VERSION
#+end_src

#+RESULTS:
: Votre branche est à jour avec 'origin/upstream'.
: Mise à jour c0f28c8..2bc7f7c
: Fast-forward
:  Changes                    | 2 ++
:  README.pod                 | 8 --------
:  build-from-git.md          | 6 ------
:  lib/App/Cme/Command/fix.pm | 1 +
:  4 files changed, 3 insertions(+), 14 deletions(-)

Update debian branch:
#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  git checkout debian/latest
  git merge upstream
#+end_src

#+RESULTS:
: Votre branche est à jour avec 'origin/debian/latest'.
: Merge made by the 'ort' strategy.
:  Changes                    | 2 ++
:  README.pod                 | 8 --------
:  build-from-git.md          | 6 ------
:  lib/App/Cme/Command/fix.pm | 1 +
:  4 files changed, 3 insertions(+), 14 deletions(-)

Update the debian/copyright file:
#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  cme update dpkg-copyright
#+end_src

Then review the changes and commit the result.

See also https://github.com/dod38fr/config-model/wiki/Updating-debian-copyright-file-with-cme

Check patches (and cleanup if necessary):
#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  quilt push --refresh -a && quilt pop -a
#+end_src

#+RESULTS:
#+begin_example
Application de fix-cme-shebang
patching file bin/cme
Patch fix-cme-shebang is unchanged

Application de force-load-bash-comp-plugins
patching file contrib/bash_completion.cme
Patch force-load-bash-comp-plugins is unchanged

Application de add_dh_config
patching file dist.ini
Patch add_dh_config is unchanged

Application de rm-git-from-dzil
patching file dist.ini
Patch rm-git-from-dzil is unchanged

Le patch rm-git-from-dzil est maintenant au sommet
Retrait de rm-git-from-dzil
Restoring dist.ini

Retrait de add_dh_config
Restoring dist.ini

Retrait de force-load-bash-comp-plugins
Restoring contrib/bash_completion.cme

Retrait de fix-cme-shebang
Restoring bin/cme

Aucun patch n'est appliqué
#+end_example
Generate a temporary changelog:
#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  gbp dch --new-version=$VERSION-1 --snapshot --auto debian/
#+end_src

#+RESULTS:
: gbp:info: Found tag for topmost changelog version '82ddfbdf75c6059a07fd02757b4e9c8d0ed00e42'
: gbp:info: Continuing from commit '82ddfbdf75c6059a07fd02757b4e9c8d0ed00e42'
: gbp:info: Only looking for changes on 'debian/'
: gbp:info: No changes detected from 82ddfbdf75c6059a07fd02757b4e9c8d0ed00e42 to HEAD.
: gbp:info: Changelog 1.049-1~1.gbp6e0a28 (snapshot #1) prepared up to 6e0a287

Commit =debian/changelog= (otherwise, =gbp buildpackage= tries to build the
old version):

#+begin_src shell :dir .. :exports code :results verbatim :var VERSION=version
  git commit -m"new upstream version" debian/changelog
#+end_src

#+RESULTS:
: [debian/latest 0863035] new upstream version
:  1 file changed, 8 insertions(+)

You can build the package with the following command:

# this requires emacs ob-tmux
#+begin_src tmux :session build :results verbatim :exports code :var dir=repo_dir
  cd $dir
  gbp buildpackage --git-ignore-new
#+end_src

Note: only committed changes are used by =gbp buildpackage=

Update the changelog:

#+begin_src tmux :session build :results verbatim :exports code :var dir=repo_dir
  cd $dir
  gbp dch -Ra --commit
#+end_src

Build the package:

# this requires emacs ob-tmux
#+begin_src tmux :session build :results verbatim :exports code :var dir=repo_dir
  cd $dir
  gbp buildpackage
#+end_src

Once everything is fine, build a source package and tag:

#+begin_src tmux :session build :results verbatim :exports code :var dir=repo_dir
  cd $dir
  gbp buildpackage -S --git-tag
#+end_src

Push on salsa:

#+begin_src shell :dir ".." :results verbatim :exports code
  gbp push
#+end_src

For more details, see [[https://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.import.upstream-git.html#gbp.import.upstream.git.notarball][gbp import with git documentation]].

# this is a workaround for a bug in ob-tmux. No need to execute this
#+NAME: repo_dir
#+BEGIN_SRC shell :results verbatim :exports no
  cd ..
  echo -n $PWD
#+END_SRC

