diff --git a/CHANGELOG.md b/CHANGELOG.md index 805a5f0..c3b2e12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.5.1] - 2023-05-10 + +### Fixed + +- Switching academy version in gitlab-ci include causes ci error. +- Distribute not working due to invalid variable. + +### Added + +- Add --force-merge param to distribute. + ## [0.5.0] - 2023-05-02 _Stable release based on [0.5.0-rc.1]._ @@ -32,6 +43,7 @@ _Stable release based on [0.5.0-rc.1]._ - Set name of distributed project as `original_project_name user_name` +[0.5.1]: https://https://github.com/internetguru/academy/compare/v0.5.0...v0.5.1 [0.5.0]: https://https://github.com/internetguru/academy/compare/v0.4.0...v0.5.0 [0.5.0-rc.1]: https://github.com/internetguru/academy/releases/tag/v0.4.0 [0.4.0]: https://github.com/internetguru/academy/compare/v0.3.0...v0.4.0 diff --git a/VERSION b/VERSION index 8f0916f..4b9fcbe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 +0.5.1 diff --git a/distribute b/distribute index 6f2deb4..8c6b28d 100755 --- a/distribute +++ b/distribute @@ -92,9 +92,15 @@ update_user_repo() { git_add_all "${user_cache_folder}" git_commit "${user_cache_folder}" '-m "Update assignment"' git_push "${user_cache_folder}" '--all' - declare project_id - request_exists \ - || create_request + if [[ $FORCE_MERGE == 1 ]]; then + git_checkout "${user_cache_folder}" "${user_default_branch}" + git_merge "${user_cache_folder}" '--no-ff' "${SOURCE_BRANCH}" + git_push "${user_cache_folder}" origin "${user_default_branch}" + git_checkout "${user_cache_folder}" "${SOURCE_BRANCH}" + else + request_exists \ + || create_request + fi copy_issues set_public_pages "${project_id}" >/dev/null } @@ -294,11 +300,12 @@ declare -i ISSUES_COUNT=0 declare -i issues_count_src="${ISSUES_COUNT}" # shellcheck disable=SC2034 declare ACADEMY_GITLAB_ACCESS_TOKEN +declare FORCE_MERGE=0 # get options declare OPT -OPT="$(getopt --name "${0}" --options 'a:d:hi:lno:p:s:r:' \ - --longoptions 'assign:,help,process-issues:,update-links,default-branch-namespace:,dry-run,output-dir:,prefix:,member-role:,namespace:' \ +OPT="$(getopt --name "${0}" --options 'a:d:hi:lno:p:s:r:m' \ + --longoptions 'assign:,help,process-issues:,update-links,default-branch-namespace:,dry-run,output-dir:,prefix:,member-role:,namespace:,force-merge' \ -- "$@")" \ && eval set -- "${OPT}" \ || exit 1 @@ -332,6 +339,10 @@ while (( $# > 0 )); do || exception 'Readme file not found in WORKING_DIR' shift ;; + -m|--force-merge) + FORCE_MERGE=1 + shift + ;; -n|--dry-run) DRY_RUN='true' shift diff --git a/gitlab-stages.yml b/gitlab-stages.yml index d6311b5..e776b15 100644 --- a/gitlab-stages.yml +++ b/gitlab-stages.yml @@ -18,6 +18,7 @@ variables: ACADEMY_DOCKER_IMAGE: ${ACADEMY_DEFAULT_DOCKER_IMAGE} ACADEMY_CACHE: "../.academy-cache" ACADEMY_EDITABLE: "*.*" + ACADEMY_FORCE_MERGE: "" cache: - key: academy-cache @@ -47,7 +48,9 @@ cache: fi if [[ -d "${ACADEMY_DIR}/.git" ]]; then git -C "${ACADEMY_DIR}" reset --hard - git -C "${ACADEMY_DIR}" pull origin ${revision} + git -C "${ACADEMY_DIR}" config --replace-all remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + git -C "${ACADEMY_DIR}" fetch origin ${revision} + git -C "${ACADEMY_DIR}" checkout origin/${revision} else git clone --single-branch --branch ${revision} https://github.com/InternetGuru/academy ${ACADEMY_DIR} fi @@ -180,7 +183,11 @@ distribute: # TODO remove other existing repositories else users="$(get_users)" - ${ACADEMY} distribute --update-links --namespace "${user_namespace}" \ + declare merge='' + if [[ -n "${ACADEMY_FORCE_MERGE}" ]]; then + merge='--force-merge' + fi + ${ACADEMY} distribute ${merge} --update-links --namespace "${user_namespace}" \ --process-issues "${ACADEMY_ISSUES:-${CI_COMMIT_REF_NAME}}" \ <<< "${users}" fi