mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-15 20:09:18 -05:00
Go 1.7: {{if}} branches end in different contexts #977
Closed
opened 2025-11-02 03:44:01 -06:00 by GiteaMirror
·
38 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1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4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#977
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @strk on GitHub (Aug 18, 2017).
As of commit
e08d1fcc15(current master branch) new installation fails with following error:Gitea has been built with
go build.The offending route is the default one (/) which is were you are directed right after install.
@lafriks commented on GitHub (Aug 18, 2017):
strange, I can't seem to be able to reproduce that. Not in new install, not in existing one. Built with
TAGS="sqlite" make build@strk commented on GitHub (Aug 18, 2017):
Here I have go version go1.7.4 linux/amd64
The other specificity of my install is that I'm using an existing PostgreSQL database, with a user in it.
When cleaning cookies the error appears after login.
@strk commented on GitHub (Aug 18, 2017):
I can still reproduce with
TAGS="sqlite" make buildbuilds (and sqlite3 database).In this case I have to register a new user before logging in, and get that error upon first login.
@strk commented on GitHub (Aug 18, 2017):
The template does indeed look weird, check this snippet:
What's that
v-if??@daviian commented on GitHub (Aug 18, 2017):
@strk It's from Vue.js. Do you use Chrome? Chrome has an intriguing caching now. Open your public/index.js in a seperate tab and reload. Maybe you have an old js file.
@strk commented on GitHub (Aug 18, 2017):
Ok, anyway the problem is somewhere in here, at the top of templates/user/dashboard/repo-search.tmpl:
Removing the portion inside the condition, leaving the following, fixes it:
@daviian commented on GitHub (Aug 18, 2017):
I can't reproduce that error as well. I am on latest master. My Go version is 1.8.3
@strk commented on GitHub (Aug 18, 2017):
What Go version are you using ? What else could be different ?
@daviian commented on GitHub (Aug 18, 2017):
As I said, Go version is 1.8.3
Have you tried hard resetting your git repository to remove old folders etc.? Just an idea.
@strk commented on GitHub (Aug 18, 2017):
@lafriks are you also using Go 1.8 ? Both: any chance you can try an older version ?
I'll repeat the steps to reproduce:
@daviian commented on GitHub (Aug 18, 2017):
@strk I will try with an older version, give me a moment.
@daviian commented on GitHub (Aug 18, 2017):
Ok I can confirm this issue with Go 1.7.4!
@strk commented on GitHub (Aug 18, 2017):
Thanks for testing ! Should this be filed upstream to Vue ? (or can you tell where else the bug is ?)
@daviian commented on GitHub (Aug 18, 2017):
I don't think Vue is responsible for this. I'd rather say to file an issue at Golang for the bug in 1.7 ;-)
@strk commented on GitHub (Aug 18, 2017):
From https://golang.org/pkg/html/template/:
Maybe we can try the dummy
{{else}}trick...@strk commented on GitHub (Aug 18, 2017):
dummy
{{else}}does not help :(@daviian commented on GitHub (Aug 18, 2017):
I found this excerpt earlier today too, but thought that won't help in any way ;-)
Why not just updating Go?
@daviian commented on GitHub (Aug 18, 2017):
There was a major change in text/template from Go 1.7.5 to 1.8.0
@strk commented on GitHub (Aug 18, 2017):
Go 1.7 is what is shipped by latest Long-Term-Support popular free unix distributions.
If we drop support for 1.7 it must be properly documented (and decided).
Me, I'd rather find a workaround than dropping support for 1.7.
Check out CHANGELOG.md, the
BREAKINGsection is where a drop of support for 1.7 would go.@daviian commented on GitHub (Aug 18, 2017):
Ok sorry, haven't thought about that.
@andyleap commented on GitHub (Aug 18, 2017):
Most likely the issue is
ffd1c781b7As the file in question is all wrapped in a <script>, 1.7.4 and before are treating it as JS, but 1.8 sees that it's not JS. Not sure how much you can do to fix it.
@strk commented on GitHub (Aug 18, 2017):
Dropping the
<script type="text/x-template" id="repo-search-template">and relative closing tag prevents the error message, but doesn't give a correct rendering. Turning the type totext/templatedoesn't prevent the error message.I'll note that this template is the only template using that
<script>hack (which is documented elsewhere to be an hack). It was introduced with PR #2285@daviian commented on GitHub (Aug 18, 2017):
I think the script tag exists because it is a Vue template and not a Go html/template.
@strk commented on GitHub (Aug 18, 2017):
According to https://sebastiandedeyne.com/posts/2016/dealing-with-templates-in-vue-20 even documentation discourage from using the
x-templatetrick.@strk commented on GitHub (Aug 18, 2017):
Comment from #go-nuts IRC channel:
@lafriks commented on GitHub (Aug 18, 2017):
@strk yes it is not best practice but currently it would be quite big task to move template out to Vue files/templates as it would need to create way to get translations to javascript + add webpack javascript build step. What could be done currently to support do not use Vue component but directly use Vue app for this. This would fix the go 1.7 problem
@lafriks commented on GitHub (Aug 18, 2017):
@Morlinest can you for now make that vue component back to vue app so not to use script template so that Gitea can be compiled with GoLang 1.7 again? After 1.2 is released we should make correct solution with component moved to vue file and webpack build step
@Morlinest commented on GitHub (Aug 18, 2017):
@strk @lafriks Interesting ... I can make some changes, for example use
inline-templateinstead (or back toVue). Can you try first if #2317 can fix it? Did you try it beforex-templatewas used?@Morlinest commented on GitHub (Aug 18, 2017):
If #2317 does not help, aslo try to include code from
repo-search.tmpldirectly todashboard.tmpl.@daviian commented on GitHub (Aug 18, 2017):
@Morlinest The problem is the <script>-tag. As it tells the templating engine of Go 1.7 to interpret this part as JS. Mentioned in https://github.com/go-gitea/gitea/issues/2331#issuecomment-323440737
Don't think copying the <script> part directly to dashboard.tmpl resolves the issue.
@strk commented on GitHub (Aug 18, 2017):
#2317 seems to fix it for me. Do you confirm @daviian ?
@lafriks commented on GitHub (Aug 18, 2017):
@strk it will fix template compile error but will not fix rendering on 1.7 as it will escape translations as if they are part of javascript that is not correct.
@lafriks commented on GitHub (Aug 18, 2017):
@Morlinest I think currently it is needed to change it back to Vue app
@daviian commented on GitHub (Aug 18, 2017):
@strk Yes I can confirm, however there are lots of errors.
imo @lafriks is right. The best solution would be a complete webpack build chain and a clean separation between Vue templates and Go templates. I guess this is not doable for 1.2.0
@Morlinest commented on GitHub (Aug 18, 2017):
OK, just
<script>tag is no no. I'll do something with it.@Morlinest commented on GitHub (Aug 18, 2017):
Please try #2336
@daviian commented on GitHub (Aug 18, 2017):
@Morlinest Fixes the issue 👍
@Morlinest commented on GitHub (Aug 18, 2017):
@daviian Great, thanks for test.