Skip to content

Commit

Permalink
Merge branch 'main' into use-git-log-raw
Browse files Browse the repository at this point in the history
  • Loading branch information
techknowlogick committed Jun 19, 2021
2 parents 1df9e44 + 6667f52 commit 749a19e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: List of keywords used in Pull Request comments to automatically reopen
a related issue
- `DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT`: **50**: In the default merge message for squash commits include at most this many commits. Set to `-1` to include all commits
- `DEFAULT_MERGE_MESSAGE_SIZE`: **5120**: In the default merge message for squash commits limit the size of the commit messages. Set to `-1` to have no limit.
- `DEFAULT_MERGE_MESSAGE_SIZE`: **5120**: In the default merge message for squash commits limit the size of the commit messages. Set to `-1` to have no limit. Only used if `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES` is `true`.
- `DEFAULT_MERGE_MESSAGE_ALL_AUTHORS`: **false**: In the default merge message for squash commits walk all commits to include all authors in the Co-authored-by otherwise just use those in the limited list
- `DEFAULT_MERGE_MESSAGE_MAX_APPROVERS`: **10**: In default merge messages limit the number of approvers listed as `Reviewed-by:`. Set to `-1` to include all.
- `DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY`: **true**: In default merge messages only include approvers who are officially allowed to review.
- `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request.

### Repository - Issue (`repository.issue`)

Expand Down
3 changes: 3 additions & 0 deletions modules/setting/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var (
DefaultMergeMessageAllAuthors bool
DefaultMergeMessageMaxApprovers int
DefaultMergeMessageOfficialApproversOnly bool
PopulateSquashCommentWithCommitMessages bool
} `ini:"repository.pull-request"`

// Issue Setting
Expand Down Expand Up @@ -199,6 +200,7 @@ var (
DefaultMergeMessageAllAuthors bool
DefaultMergeMessageMaxApprovers int
DefaultMergeMessageOfficialApproversOnly bool
PopulateSquashCommentWithCommitMessages bool
}{
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
// Same as GitHub. See
Expand All @@ -210,6 +212,7 @@ var (
DefaultMergeMessageAllAuthors: false,
DefaultMergeMessageMaxApprovers: 10,
DefaultMergeMessageOfficialApproversOnly: true,
PopulateSquashCommentWithCommitMessages: false,
},

// Issue settings
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ pulls.manually_merged_as=Dieser Pull Request wurde manuell als <a rel="nofollow"
pulls.is_closed=Der Pull-Request wurde geschlossen.
pulls.has_merged=Der Pull-Request wurde gemergt.
pulls.title_wip_desc=`<a href="#">Beginne den Titel mit <strong>%s</strong></a> um zu verhindern, dass der Pull Request versehentlich gemergt wird.`
pulls.cannot_merge_work_in_progress=Dieser Pull Request ist als Work in Progress markiert.
pulls.data_broken=Dieser Pull-Requests ist kaputt, da Fork-Informationen gelöscht wurden.
pulls.files_conflicted=Dieser Pull-Request hat Änderungen, die im Widerspruch zum Ziel-Branch stehen.
pulls.is_checking=Die Konfliktprüfung läuft noch. Bitte aktualisiere die Seite in wenigen Augenblicken.
Expand Down
15 changes: 15 additions & 0 deletions options/locale/locale_es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ loading=Cargando…
step1=Paso 1:
step2=Paso 2:

error=Error
error404=La página a la que está intentando acceder o <strong>no existe</strong> o <strong>no está autorizado</strong> para verla.

never=Nunca

[error]
occurred=Se ha producido un error
Expand Down Expand Up @@ -731,6 +733,7 @@ mirror_lfs_desc=Activar la reproducción de datos LFS.
mirror_lfs_endpoint=Punto final de LFS
mirror_lfs_endpoint_desc=Sync intentará usar la url del clon para <a target="_blank" rel="noopener noreferrer" href="%s">determinar el servidor LFS</a>. También puede especificar un punto final personalizado si los datos LFS del repositorio se almacenan en otro lugar.
mirror_last_synced=Sincronizado por última vez
mirror_password_placeholder=(Sin cambios)
watchers=Seguidores
stargazers=Fans
forks=Forks
Expand Down Expand Up @@ -783,6 +786,7 @@ form.reach_limit_of_creation_n=Ya han alcanzado su límite de repositorios de %d
form.name_reserved=El nombre de repositorio '%s' está reservado.
form.name_pattern_not_allowed=El patrón '%s' no está permitido en un nombre de repositorio.

need_auth=Autorización
migrate_options=Opciones de migración
migrate_service=Servicio de Migración
migrate_options_mirror_helper=Este repositorio será uno <span class="text blue">replicado</span>
Expand Down Expand Up @@ -1314,6 +1318,7 @@ pulls.manually_merged_as=El Pull Request se ha fusionado manualmente como <a rel
pulls.is_closed=El pull request ha sido cerrado.
pulls.has_merged=El pull request ha sido fusionado.
pulls.title_wip_desc=`<a href="#">Comience el título con <strong>%s</strong></a> para prevenir que el pull request se fusione accidentalmente.`
pulls.still_in_progress=¿Aún en curso?
pulls.data_broken=Este pull request está rota debido a que falta información del fork.
pulls.files_conflicted=Este pull request tiene cambios en conflicto con la rama de destino.
pulls.is_checking=La comprobación de conflicto de fusión está en progreso. Inténtalo de nuevo en unos momentos.
Expand Down Expand Up @@ -1539,6 +1544,11 @@ settings.hooks=Webhooks
settings.githooks=Git Hooks
settings.basic_settings=Configuración Básica
settings.mirror_settings=Configuración de réplica
settings.mirror_settings.docs=Configure su proyecto para insertar y/o extraer automáticamente los cambios hacia/desde otro repositorio. Las ramas, etiquetas y commits se sincronizarán automáticamente. <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/repo-mirror/">¿Cómo replico los repositorios?</a>
settings.mirror_settings.direction=Dirección
settings.mirror_settings.direction.pull=Pull
settings.mirror_settings.last_update=Última actualización
settings.mirror_settings.push_mirror.remote_url=URL del repositorio remoto de Git
settings.sync_mirror=Sincronizar ahora
settings.mirror_sync_in_progress=La sincronización del repositorio replicado está en curso. Vuelva a intentarlo más tarde.
settings.email_notifications.enable=Habilitar las notificaciones por correo electrónico
Expand Down Expand Up @@ -1604,6 +1614,7 @@ settings.transfer_form_title=Escriba el nombre del repositorio como confirmació
settings.transfer_in_progress=Actualmente hay una transferencia en curso. Por favor, cancela si quieres transferir este repositorio a otro usuario.
settings.transfer_notices_1=- Perderá el acceso al repositorio si lo transfiere a un usuario individual.
settings.transfer_notices_2=- Mantendrá el acceso al repositorio si lo transfiere a una organización que usted (co-)posee.
settings.transfer_notices_3=- Si el repositorio es privado y se transfiere a un usuario individual, esta acción se asegura de que el usuario tenga al menos permisos de lectura (y cambie los permisos si es necesario).
settings.transfer_owner=Nuevo Propietario
settings.transfer_perform=Realizar transferencia
settings.transfer_started=Este repositorio ha sido marcado para transferencia y espera confirmación de "%s"
Expand Down Expand Up @@ -1974,6 +1985,10 @@ branch.restore=Restaurar rama '%s'
branch.download=Descargar rama '%s'
branch.included_desc=Esta rama forma parte de la predeterminada
branch.included=Incluida
branch.create_new_branch=Crear rama desde la rama:
branch.confirm_create_branch=Crear rama
branch.new_branch=Crear nueva rama
branch.new_branch_from=Crear nueva rama desde '%s'

tag.create_tag=Crear etiqueta <strong>%s</strong>
tag.create_success=La etiqueta '%s' ha sido creada.
Expand Down
4 changes: 2 additions & 2 deletions options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,8 @@ issues.review.dismissed_label=Rejeté
issues.review.left_comment=laisser un commentaire
issues.review.content.empty=Vous devez laisser un commentaire indiquant le(s) changement(s) demandé(s).
issues.review.reject=a requis les changements %s
issues.review.wait=a demandé une révision pour %s
issues.review.add_review_request=demande de révision de %s %s
issues.review.wait=a été sollicité pour une révision %s
issues.review.add_review_request=a demandé une révision de %s %s
issues.review.remove_review_request=a supprimé la demande de révision pour %s %s
issues.review.remove_review_request_self=a refusé la revue %s
issues.review.pending=En attente
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ settings.visibility.public=Публичный
settings.visibility.limited=Ограничено (Видно только для авторизованных пользователей)
settings.visibility.limited_shortname=Ограничить
settings.visibility.private=Частный (Видимый только для участников организации)
settings.visibility.private_shortname=Приватизировать
settings.visibility.private_shortname=Приватный

settings.update_settings=Обновить настройки
settings.update_setting_success=Настройки организации обновлены.
Expand Down
22 changes: 22 additions & 0 deletions options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ loading=正在加载...
step1=第一步:
step2=第二步:

error=错误
error404=您正尝试访问的页面 <strong>不存在</strong> 或 <strong>您尚未被授权</strong> 查看该页面。

never=从不

[error]
occurred=发生错误
Expand Down Expand Up @@ -724,6 +726,7 @@ mirror_prune_desc=删除过时的远程跟踪引用
mirror_interval=镜像间隔 (有效时间单位为 "h"、"m"、"s")。0将禁用自动同步。
mirror_interval_invalid=镜像间隔无效。
mirror_address=从URL克隆
mirror_address_desc=在授权框中输入必要的凭据。
mirror_address_url_invalid=URL无效。请检查您所输入的URL是否正确。
mirror_address_protocol_invalid=提供的 url 无效。只能从 http(s):// 或 git:// 位置进行镜像。
mirror_lfs=大文件存储 (LFS)
Expand Down Expand Up @@ -786,6 +789,7 @@ form.reach_limit_of_creation_n=你已经达到了 %d 个仓库的上限。
form.name_reserved=仓库名称 '%s' 是被保留的。
form.name_pattern_not_allowed=仓库名称中不允许使用模式 "%s"。
need_auth=授权
migrate_options=迁移选项
migrate_service=迁移服务
migrate_options_mirror_helper=该仓库将是一个 <span class="text blue">镜像</span>
Expand Down Expand Up @@ -819,11 +823,19 @@ migrated_from_fake=从 %[1]s 迁移成功
migrate.migrate=从 %s 迁移
migrate.migrating=正在从 <b>%s</b> 迁移...
migrate.migrating_failed=从 <b>%s</b> 迁移失败。
migrate.migrating_failed.error=错误:%s
migrate.github.description=从 Github.com 或者 Github Enterprise 迁移数据
migrate.git.description=从 Git 迁移数据
migrate.gitlab.description=从 GitLab.com 或者 自部署 GitLab 迁移数据
migrate.gitea.description=从 Gitea.com 或 自托管 Gitea 服务器迁移数据。
migrate.gogs.description=正从 notabug.org 或其他自托管 Gogs 服务器迁移数据。
migrate.migrating_git=迁移Git数据
migrate.migrating_topics=迁移主题
migrate.migrating_milestones=迁移里程碑
migrate.migrating_labels=迁移标签
migrate.migrating_releases=迁移发布
migrate.migrating_issues=迁移工单
migrate.migrating_pulls=迁移合并请求
mirror_from=镜像自地址
forked_from=派生自
Expand Down Expand Up @@ -1546,6 +1558,15 @@ settings.hooks=Web 钩子
settings.githooks=管理 Git 钩子
settings.basic_settings=基本设置
settings.mirror_settings=镜像设置
settings.mirror_settings.docs=将你的项目设置成自动从其它存储库推送或拉取变更。分支、标签以及提交将会自动同步。<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/repo-mirror/">如何镜像存储库?</a>
settings.mirror_settings.mirrored_repository=镜像库
settings.mirror_settings.direction=方向
settings.mirror_settings.direction.pull=拉取
settings.mirror_settings.direction.push=推送
settings.mirror_settings.last_update=最后更新
settings.mirror_settings.push_mirror.none=未配置推送镜像
settings.mirror_settings.push_mirror.remote_url=Git 远程存储库链接
settings.mirror_settings.push_mirror.add=添加推送镜像
settings.sync_mirror=同步
settings.mirror_sync_in_progress=镜像同步正在进行中,请稍后后再试。
settings.email_notifications.enable=启用邮件通知
Expand Down Expand Up @@ -1611,6 +1632,7 @@ settings.transfer_form_title=输入仓库名称以做确认:
settings.transfer_in_progress=当前正在进行转让。 如果你想将此代码库转让给另一个用户,请取消它。
settings.transfer_notices_1=-如果将其传输给单个用户, 您将失去对存储库的访问权限。
settings.transfer_notices_2=-如果将其转移到您 (共同) 拥有的组织,您可以继续访问该仓库。
settings.transfer_notices_3=- 如果存储库是私有的并且被转移给某个用户,那么此操作可以确保该用户至少具有读权限(以及必要时的更改权限)。
settings.transfer_owner=新拥有者
settings.transfer_perform=执行转让
settings.transfer_started=该代码库已被标记为转让并等待来自 %s 的确认
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ email_notifications.disable=關閉郵件通知
email_notifications.submit=套用郵件偏好設定

[repo]
new_repo_helper=儲存庫包含所以專案檔案,包含修訂歷史。已經存放於別處了嗎?<a href="%s">遷移儲存庫。</a>
new_repo_helper=儲存庫包含所有專案檔案,包含修訂歷史。已經存放於別處了嗎?<a href="%s">遷移儲存庫。</a>
owner=擁有者
owner_helper=組織可能因為儲存庫數量上限而未列入此選單。
repo_name=儲存庫名稱
Expand Down
36 changes: 32 additions & 4 deletions services/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,44 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
authors := make([]string, 0, list.Len())
stringBuilder := strings.Builder{}

stringBuilder.WriteString(pr.Issue.Content)
if stringBuilder.Len() > 0 {
stringBuilder.WriteRune('\n')
stringBuilder.WriteRune('\n')
if !setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
stringBuilder.WriteString(pr.Issue.Content)
if stringBuilder.Len() > 0 {
stringBuilder.WriteRune('\n')
stringBuilder.WriteRune('\n')
}
}

// commits list is in reverse chronological order
element := list.Back()
for element != nil {
commit := element.Value.(*git.Commit)

if setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
maxSize := setting.Repository.PullRequest.DefaultMergeMessageSize
if maxSize < 0 || stringBuilder.Len() < maxSize {
var toWrite []byte
if element == list.Back() {
toWrite = []byte(strings.TrimPrefix(commit.CommitMessage, pr.Issue.Title))
} else {
toWrite = []byte(commit.CommitMessage)
}

if len(toWrite) > maxSize-stringBuilder.Len() && maxSize > -1 {
toWrite = append(toWrite[:maxSize-stringBuilder.Len()], "..."...)
}
if _, err := stringBuilder.Write(toWrite); err != nil {
log.Error("Unable to write commit message Error: %v", err)
return ""
}

if _, err := stringBuilder.WriteRune('\n'); err != nil {
log.Error("Unable to write commit message Error: %v", err)
return ""
}
}
}

authorString := commit.Author.String()
if !authorsMap[authorString] && authorString != posterSig {
authors = append(authors, authorString)
Expand Down

0 comments on commit 749a19e

Please sign in to comment.