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

Make WIP prefixes case insensitive, e.g. allow Draft as a WIP prefix #19780

Merged
merged 6 commits into from
May 26, 2022

Conversation

certik
Copy link
Contributor

@certik certik commented May 22, 2022

There is a bug in WIP prefix matching which results in only all uppercase prefixes being matched.

The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in WORK_IN_PROGRESS_PREFIXES. As a result,
the following did not work:

WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use Draft (as well as DRAFT) in the title.
However, the link Start the title with DRAFT: to prevent the pull request from being merged accidentally. showed the suggestion in uppercase; so
it is not possible to show it as Draft. This PR fixes it, and allows
to use Draft in WORK_IN_PROGRESS_PREFIXES.

Fixes #19779.

The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result,
the following did not work:

    WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

    WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use `Draft` (as well as `DRAFT`) in the title.
However, the link `Start the title with DRAFT: to prevent the pull request
from being merged accidentally.` showed the suggestion in uppercase; so
it is not possible to show it as `Draft`. This PR fixes it, and allows
to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`.

Fixes go-gitea#19779.
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@a9af93c). Click here to learn what that means.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main   #19780   +/-   ##
=======================================
  Coverage        ?   47.28%           
=======================================
  Files           ?      957           
  Lines           ?   133339           
  Branches        ?        0           
=======================================
  Hits            ?    63053           
  Misses          ?    62617           
  Partials        ?     7669           
Impacted Files Coverage Δ
models/pull.go 55.90% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9af93c...93ed7a0. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 22, 2022
@zeripath
Copy link
Contributor

You also need to fix GetWorkInProgressPrefix() a few lines below that.

@zeripath
Copy link
Contributor

zeripath commented May 22, 2022

In actuality I think the better solution would be to go to modules/setting/repository.go line 297 and uppercase the WorkInProgressPrefixes just after reading them from the configuration file.


Oh I see these are suggested to the User as potential prefixes in which case permanently uppercasing them is not ideal.

@Gusted Gusted added this to the 1.17.0 milestone May 22, 2022
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 22, 2022
@lunny
Copy link
Member

lunny commented May 22, 2022

It's better to update the comment or document that is not case sensitive.

@certik
Copy link
Contributor Author

certik commented May 22, 2022

In actuality I think the better solution would be to go to modules/setting/repository.go line 297 and uppercase the WorkInProgressPrefixes just after reading them from the configuration file.

I think that would be equivalent to the workaround I mentioned: WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP], which works, but then Gitea puts DRAFT instead of Draft into the suggested prefix for Work in Progress. So I think a better solution is the one provided in this PR.

You also need to fix GetWorkInProgressPrefix() a few lines below that.

Excellent point, fixed in 11754a1. This is needed so that the "Remove Draft Prefix" button works. I tested it and it seems to work.

@zeripath
Copy link
Contributor

Cool. Thanks...

It would be helpful to update:

;; List of prefixes used in Pull Request title to mark them as Work In Progress

and

title to mark them as Work In Progress

To mention that these are matched in a case insensitive manner too. Then I will approve and we can get this merged.

@certik
Copy link
Contributor Author

certik commented May 26, 2022

@zeripath I made the changes, good point. Let me know if there is anything else to be done.

custom/conf/app.example.ini Outdated Show resolved Hide resolved
docs/content/doc/advanced/config-cheat-sheet.en-us.md Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 26, 2022
@zeripath zeripath changed the title Make Draft working as a WIP prefix Make WIP prefixes case insensitive, e.g. allow Draft as a WIP prefix May 26, 2022
@zeripath
Copy link
Contributor

make lgtm work

@zeripath zeripath merged commit 8720f87 into go-gitea:main May 26, 2022
@zeripath
Copy link
Contributor

zeripath commented May 26, 2022

I think it would be appropriate to backport this to 1.16.

If you would like to do this:

In your git repo

## Update your repo
git pull --all
 
## Checkout a backport branch
git checkout origin/release/v1.16 -b backport-19780-v1.16

## Cherry pick the above commit
git cherry-pick 8720f87

## and fix any conflicts...

## Adjust the commit message to make the first line after the title (and its blank line):
## Backport #19780 
git commit --amend

## Push it up
git push certik backport-19780-v1.16

## Then open a PR
xdg-open https://github.com/go-gitea/gitea/compare/release/v1.16...certik:backport-19780-v1.16

## Put it on the v1.16.9 milestone with the label: kind/bug
## And then one of us will add the backport/done label to this.

zjjhot added a commit to zjjhot/gitea that referenced this pull request May 26, 2022
* giteaofficial/main:
  Make WIP prefixes case insensitive, e.g. allow `Draft` as a WIP prefix (go-gitea#19780)
  Fix follower display on user page (go-gitea#19805)
  Show source/target branches on PR's list (go-gitea#19747)
certik added a commit to certik/gitea that referenced this pull request May 26, 2022
go-gitea#19780)

Backport go-gitea#19780

The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result,
the following did not work:

    WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

    WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use `Draft` (as well as `DRAFT`) in the title.
However, the link `Start the title with DRAFT: to prevent the pull request
from being merged accidentally.` showed the suggestion in uppercase; so
it is not possible to show it as `Draft`. This PR fixes it, and allows
to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`.

Fixes go-gitea#19779.

Co-authored-by: zeripath <art27@cantab.net>
@certik
Copy link
Contributor Author

certik commented May 26, 2022

@zeripath thanks for fixing it up and merging. I backported it here: #19811, it seems I am not allowed to change milestones and labels, so you'll have to do that.

@zeripath zeripath added the backport/done All backports for this PR have been created label May 26, 2022
lafriks pushed a commit that referenced this pull request May 26, 2022
#19780) (#19811)

Backport #19780

The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result,
the following did not work:

    WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

    WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use `Draft` (as well as `DRAFT`) in the title.
However, the link `Start the title with DRAFT: to prevent the pull request
from being merged accidentally.` showed the suggestion in uppercase; so
it is not possible to show it as `Draft`. This PR fixes it, and allows
to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`.

Fixes #19779.

Co-authored-by: zeripath <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this pull request Jun 20, 2022
## [1.16.9](https://github.com/go-gitea/gitea/releases/tag/1.16.9) - 2022-06-20

* BUGFIXES
  * Fix permission check for delete tag (go-gitea#19985) (go-gitea#20001)
  * Only log non ErrNotExist errors in git.GetNote  (go-gitea#19884) (go-gitea#19905)
  *  Use exact search instead of fuzzy search for branch filter dropdown (go-gitea#19885) (go-gitea#19893)
  * Set Setpgid on child git processes (go-gitea#19865) (go-gitea#19881)
  * Import git from alpine 3.16 repository as 2.30.4 is needed for `safe.directory = '*'` to work but alpine 3.13 has 2.30.3 (go-gitea#19876)
  * Ensure responses are context.ResponseWriters (go-gitea#19843) (go-gitea#19859)
  * Fix count bug (go-gitea#19850)
  * Fix raw endpoint PDF file headers (go-gitea#19825) (go-gitea#19826)
  * Make WIP prefixes case insensitive, e.g. allow `Draft` as a WIP prefix (go-gitea#19780) (go-gitea#19811)
  * Fix NotificationUnreadCount (go-gitea#19802)
  * Prevent NPE when cache service is disabled (go-gitea#19703) (go-gitea#19783)
  * Detect truncated utf-8 characters at the end of content as still representing utf-8 (go-gitea#19773) (go-gitea#19774)
  * Fix doctor pq: syntax error at or near "." quote user table name (go-gitea#19765) (go-gitea#19770)
  * Fix bug (go-gitea#19757)

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath mentioned this pull request Jun 20, 2022
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
go-gitea#19780)

The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result,
the following did not work:

    WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

    WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use `Draft` (as well as `DRAFT`) in the title.
However, the link `Start the title with DRAFT: to prevent the pull request
from being merged accidentally.` showed the suggestion in uppercase; so
it is not possible to show it as `Draft`. This PR fixes it, and allows
to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`.

Fixes go-gitea#19779.

Co-authored-by: zeripath <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WORK_IN_PROGRESS_PREFIXES=Draft: still allows to merge "Draft" merge requests
6 participants