Skip to content

Commit c7f4c9c

Browse files
Merge branch 'master' into fix-go-gitea#6946-stop-running-hooks-on-pr-merge
2 parents 9a6658f + 68a83cc commit c7f4c9c

15 files changed

+918
-140
lines changed

.drone.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pipeline:
5050
pull: true
5151
commands:
5252
- npm install
53-
- make stylesheets-check
53+
- make css
54+
- make js
5455
when:
5556
event: [ push, tag, pull_request ]
5657

.eslintrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
root: true
2+
3+
extends:
4+
- eslint:recommended
5+
6+
parserOptions:
7+
ecmaVersion: 2015
8+
9+
env:
10+
browser: true
11+
jquery: true
12+
es6: true
13+
14+
globals:
15+
Clipboard: false
16+
CodeMirror: false
17+
emojify: false
18+
SimpleMDE: false
19+
Vue: false
20+
Dropzone: false
21+
u2fApi: false
22+
hljs: false
23+
24+
rules:
25+
no-unused-vars: [error, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, ignoreRestSiblings: true}]

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ high-level discussions.
6565
## Testing redux
6666

6767
Before submitting a pull request, run all the tests for the whole tree
68-
to make sure your changes don't cause regression elsewhere.
68+
to make sure your changes don't cause regression elsewhere.
6969

70-
Here's how to run the test suite:
70+
Here's how to run the test suite:
7171

7272
- Install the correct version of the drone-cli package. As of this
7373
writing, the correct drone-cli version is
7474
[0.8.6](https://0-8-0.docs.drone.io/cli-installation/).
7575
- Ensure you have enough free disk space. You will need at least
7676
15-20 Gb of free disk space to hold all of the containers drone
7777
creates (a default AWS or GCE disk size won't work -- see
78-
[#6243](https://github.com/go-gitea/gitea/issues/6243)).
78+
[#6243](https://github.com/go-gitea/gitea/issues/6243)).
7979
- Change into the base directory of your copy of the gitea repository,
8080
and run `drone exec --local --build-event pull_request`.
8181

@@ -114,7 +114,7 @@ Generally, the go build tools are installed as-needed in the `Makefile`.
114114
An exception are the tools to build the CSS and images.
115115

116116
- To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager) at version 8.0 or above
117-
with `npm` and then run `npm install` and `make generate-stylesheets`.
117+
with `npm` and then run `npm install` and `make css`.
118118
- To build Images: ImageMagick, inkscape and zopflipng binaries must be
119119
available in your `PATH` to run `make generate-images`.
120120

@@ -214,7 +214,7 @@ to the maintainers team. If a maintainer is inactive for more than 3
214214
months and forgets to leave the maintainers team, the owners may move
215215
him or her from the maintainers team to the advisors team.
216216
For security reasons, Maintainers should use 2FA for their accounts and
217-
if possible provide gpg signed commits.
217+
if possible provide gpg signed commits.
218218
https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
219219
https://help.github.com/articles/signing-commits-with-gpg/
220220

@@ -281,7 +281,7 @@ be reviewed by two maintainers and must pass the automatic tests.
281281
* Create `-dev` tag as `git tag -s -F release.notes v$vmaj.$vmin.0-dev` and push the tag as `git push origin v$vmaj.$vmin.0-dev`.
282282
* When CI has finished building tag then you have to create a new branch named `release/v$vmaj.$vmin`
283283
* If it is bugfix version create PR for changelog on branch `release/v$vmaj.$vmin` and wait till it is reviewed and merged.
284-
* Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
284+
* Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
285285
* And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically created a release and upload all the compiled binary. (But currently it didn't add the release notes automatically. Maybe we should fix that.)
286286
* If needed send PR for changelog on branch `master`.
287287
* Send PR to [blog repository](https://github.com/go-gitea/blog) announcing the release.

Makefile

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,33 +365,55 @@ release-compress:
365365
fi
366366
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
367367

368-
.PHONY: javascripts
369-
javascripts: public/js/index.js
370-
371-
.IGNORE: public/js/index.js
372-
public/js/index.js: $(JAVASCRIPTS)
373-
cat $< >| $@
374-
375-
.PHONY: stylesheets-check
376-
stylesheets-check: generate-stylesheets
377-
@diff=$$(git diff public/css/*); \
378-
if [ -n "$$diff" ]; then \
379-
echo "Please run 'make generate-stylesheets' and commit the result:"; \
380-
echo "$${diff}"; \
368+
.PHONY: js
369+
js:
370+
@if ([ ! -d "$(PWD)/node_modules" ]); then \
371+
echo "node_modules directory is absent, please run 'npm install' first"; \
381372
exit 1; \
382373
fi;
374+
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
375+
echo "Please install npm version 5.2+"; \
376+
exit 1; \
377+
fi;
378+
npx eslint public/js
383379

384-
.PHONY: generate-stylesheets
385-
generate-stylesheets:
380+
.PHONY: css
381+
css:
382+
@if ([ ! -d "$(PWD)/node_modules" ]); then \
383+
echo "node_modules directory is absent, please run 'npm install' first"; \
384+
exit 1; \
385+
fi;
386386
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
387387
echo "Please install npm version 5.2+"; \
388388
exit 1; \
389389
fi;
390-
$(eval BROWSERS := "> 1%, last 2 firefox versions, last 2 safari versions, ie 11")
391-
npx lesshint public/less/
390+
391+
npx lesshint public/less/
392392
npx lessc --clean-css="--s0 -b" public/less/index.less public/css/index.css
393393
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css="--s0 -b" public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
394-
$(foreach file, $(wildcard public/css/*),npx postcss --use autoprefixer --autoprefixer.browsers $(BROWSERS) -o $(file) $(file);)
394+
npx postcss --use autoprefixer --no-map --replace public/css/*
395+
396+
@diff=$$(git diff public/css/*); \
397+
if ([ ! -z "$CI" ] && [ -n "$$diff" ]); then \
398+
echo "Generated files in public/css have changed, please commit the result:"; \
399+
echo "$${diff}"; \
400+
exit 1; \
401+
fi;
402+
403+
.PHONY: javascripts
404+
javascripts:
405+
echo "'make javascripts' is deprecated, please use 'make js'"
406+
$(MAKE) js
407+
408+
.PHONY: stylesheets-check
409+
stylesheets-check:
410+
echo "'make stylesheets-check' is deprecated, please use 'make css'"
411+
$(MAKE) css
412+
413+
.PHONY: generate-stylesheets
414+
generate-stylesheets:
415+
echo "'make generate-stylesheets' is deprecated, please use 'make css'"
416+
$(MAKE) css
395417

396418
.PHONY: swagger-ui
397419
swagger-ui:

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false`
334334

335335
### Console log mode (`log.console`, `log.console.*`, or `MODE=console`)
336336

337-
- For the console logger `COLORIZE` will default to `true` if not on windows.
337+
- For the console logger `COLORIZE` will default to `true` if not on windows or the terminal is determined to be able to color.
338338
- `STDERR`: **false**: Use Stderr instead of Stdout.
339339

340340
### File log mode (`log.file`, `log.file.*` or `MODE=file`)
@@ -344,7 +344,6 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false`
344344
- `MAX_SIZE_SHIFT`: **28**: Maximum size shift of a single file, 28 represents 256Mb.
345345
- `DAILY_ROTATE`: **true**: Rotate logs daily.
346346
- `MAX_DAYS`: **7**: Delete the log file after n days
347-
- NB: `COLORIZE`: will default to `true` if not on windows.
348347
- `COMPRESS`: **true**: Compress old log files by default with gzip
349348
- `COMPRESSION_LEVEL`: **-1**: Compression level
350349

docs/content/doc/advanced/hacking-on-gitea.en-us.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,36 @@ You should lint, vet and spell-check with:
136136
make vet lint misspell-check
137137
```
138138

139-
### Updating the stylesheets
139+
### Updating CSS
140140

141-
To generate the stylsheets, you will need [Node.js](https://nodejs.org/) at version 8.0 or above.
141+
To generate the CSS, you will need [Node.js](https://nodejs.org/) 8.0 or greater and the build dependencies:
142142

143-
At present we use [less](http://lesscss.org/) and [postcss](https://postcss.org) to generate our stylesheets. Do
144-
**not** edit the files in `public/css/` directly, as they are generated from
145-
`lessc` from the files in `public/less/`.
143+
```bash
144+
npm install
145+
```
146146

147-
If you wish to work on the stylesheets, you will need to install `lessc` the
148-
less compiler and `postcss`. The recommended way to do this is using `npm install`:
147+
At present we use [less](http://lesscss.org/) and [postcss](https://postcss.org) to generate our CSS. Do
148+
**not** edit the files in `public/css` directly, as they are generated from `lessc` from the files in `public/less`.
149+
150+
Edit files in `public/less`, run the linter, regenerate the CSS and commit all changed files:
149151

150152
```bash
151-
cd "$GOPATH/src/code.gitea.io/gitea"
152-
npm install
153+
make css
153154
```
154155

155-
You can then edit the less stylesheets and regenerate the stylesheets using:
156+
### Updating JS
157+
158+
To run the JavaScript linter you will need [Node.js](https://nodejs.org/) 8.0 or greater and the build dependencies:
156159

157160
```bash
158-
make generate-stylesheets
161+
npm install
159162
```
160163

161-
You should commit both the changes to the css and the less files when making
162-
PRs.
164+
Edit files in `public/js` and run the linter:
165+
166+
```bash
167+
make js
168+
```
163169

164170
### Updating the API
165171

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ from `[log.sublogger]`.
213213
a stacktrace. This value is inherited.
214214
* `MODE` is the mode of the log output. It will default to the sublogger
215215
name. Thus `[log.console.macaron]` will default to `MODE = console`.
216-
* `COLORIZE` will default to `true` for `file` and `console` as
216+
* `COLORIZE` will default to `true` for `console` as
217217
described, otherwise it will default to `false`.
218218

219219
### Non-inherited default values
@@ -274,7 +274,6 @@ Other values:
274274
* `MAX_SIZE_SHIFT`: **28**: Maximum size shift of a single file, 28 represents 256Mb.
275275
* `DAILY_ROTATE`: **true**: Rotate logs daily.
276276
* `MAX_DAYS`: **7**: Delete the log file after n days
277-
* NB: `COLORIZE`: will default to `true` if not on windows.
278277
* `COMPRESS`: **true**: Compress old log files by default with gzip
279278
* `COMPRESSION_LEVEL`: **-1**: Compression level
280279

integrations/org_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ func TestPrivateOrg(t *testing.T) {
9292
req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
9393
session.MakeRequest(t, req, http.StatusNotFound)
9494

95+
// non-org member who is collaborator on repo in private org
96+
session = loginUser(t, "user4")
97+
req = NewRequest(t, "GET", "/privated_org")
98+
session.MakeRequest(t, req, http.StatusNotFound)
99+
req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org") // colab of this repo
100+
session.MakeRequest(t, req, http.StatusOK)
101+
req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
102+
session.MakeRequest(t, req, http.StatusNotFound)
103+
95104
// site admin
96105
session = loginUser(t, "user1")
97106
req = NewRequest(t, "GET", "/privated_org")

models/fixtures/collaboration.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
repo_id: 4
1010
user_id: 4
1111
mode: 2 # write
12+
13+
-
14+
id: 3
15+
repo_id: 40
16+
user_id: 4
17+
mode: 2 # write

models/repo_permission.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,17 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
168168
repo.mustOwner(e)
169169
}
170170

171-
if repo.Owner.IsOrganization() && !HasOrgVisible(repo.Owner, user) {
171+
var isCollaborator bool
172+
if user != nil {
173+
isCollaborator, err = repo.isCollaborator(e, user.ID)
174+
if err != nil {
175+
return perm, err
176+
}
177+
}
178+
179+
// Prevent strangers from checking out public repo of private orginization
180+
// Allow user if they are collaborator of a repo within a private orginization but not a member of the orginization itself
181+
if repo.Owner.IsOrganization() && !HasOrgVisible(repo.Owner, user) && !isCollaborator {
172182
perm.AccessMode = AccessModeNone
173183
return
174184
}
@@ -207,9 +217,7 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
207217
perm.UnitsMode = make(map[UnitType]AccessMode)
208218

209219
// Collaborators on organization
210-
if isCollaborator, err := repo.isCollaborator(e, user.ID); err != nil {
211-
return perm, err
212-
} else if isCollaborator {
220+
if isCollaborator {
213221
for _, u := range repo.Units {
214222
perm.UnitsMode[u.Type] = perm.AccessMode
215223
}

modules/setting/log.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"path"
1212
"path/filepath"
13-
"runtime"
1413
"strings"
1514

1615
"code.gitea.io/gitea/modules/log"
@@ -113,7 +112,6 @@ func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions
113112
panic(err.Error())
114113
}
115114

116-
logConfig["colorize"] = sec.Key("COLORIZE").MustBool(runtime.GOOS != "windows")
117115
logConfig["filename"] = logPath
118116
logConfig["rotate"] = sec.Key("LOG_ROTATE").MustBool(true)
119117
logConfig["maxsize"] = 1 << uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28))

0 commit comments

Comments
 (0)