Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to --no-history #126

Open
framillien opened this issue Jan 19, 2024 · 4 comments
Open

Alternative to --no-history #126

framillien opened this issue Jan 19, 2024 · 4 comments

Comments

@framillien
Copy link

framillien commented Jan 19, 2024

I use ghp-import with a variable prefix, to keep a disctinct doc folder by release and one for all nightly updates, like:

# version = 'latest' or a semver version
ghp-import --prefix=${version}  -m 'Update ${version}' --push doxygen_html

As you expect, without --no-history this repo growth out of control, but I need to keep data for each releases. I end up with a git-filter to squash commits from nightly builds, like:

ghp-import --prefix=${version} -m 'Update ${version}' doxygen_html
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --force --commit-filter '
    if [ "$(git rev-parse gh-pages)" != "$GIT_COMMIT" ] && [ $(git show -s --format=%B "$GIT_COMMIT" | grep -c "Update latest") -gt 0 ]
    then
        skip_commit "$@";
    else
        git commit-tree "$@";
    fi' gh-pages
git push origin +gh-pages

This command merge all commits with a common commit message the result is:

  • We keep all data, but not all commits, my releases folders are safe.
  • Repo size stay low because we squash all commits related to a nightly build

I wonder if this kind of commit squash command could be added to ghp-import as an alternative to --no-history. In the simplest form we can squash all commits of the branch without bother about commit message, or we can try to keep some ways to choose which commits should be squashed.

Could be:

-a, --squash-history      Squash commits, keeping data. If --message param
                          is set, filtering squashed commits on this commit
                          message, else squash all commits in the branch.
                          Act like `--no-history` but without discarding data.

ghp-import --prefix=${version}  -m 'Update ${version}' --push --squash-history doxygen_html

Note: -a to keep -q for potential --quiet parameter.

@framillien
Copy link
Author

This git-filter command can be tested with:

mkdir git-playground && cd git-playground
git init
touch a && git add a && git commit -m "initial"
git branch gh-pages && git checkout gh-pages
touch test1 && git add test1 && git commit -m "Update latest"
touch test2 && git add test2 && git commit -m "Update latest"
touch test3 && git add test3 && git commit -m "Update v1.0.0"
touch test4 && git add test4 && git commit -m "Update latest"
git checkout master

@c-w
Copy link
Owner

c-w commented Jan 19, 2024

Sounds good, feel free to open a pull request for this. Thanks!

@framillien
Copy link
Author

Let's go ! We continue discussion here or on the PR ?

@framillien
Copy link
Author

Hi, the PR should be in an reviewable state now, still some open subjects about stdout messages, should we add warning about potential missing tools on Windows (grep), ...

I also see that the pipeline become obsolete due to Python 2.7 checks, is it something you want to change ? Updating the min Python supported version to a 3.X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants