Skip to content

Commit 88b0add

Browse files
authored
Merge branch 'main' into refactor-of-32211
2 parents 0baab56 + 9116665 commit 88b0add

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

contrib/backport/backport.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ func main() {
6464
Value: "",
6565
Usage: "Forked user name on Github",
6666
},
67+
&cli.StringFlag{
68+
Name: "gh-access-token",
69+
Value: "",
70+
Usage: "Access token for GitHub api request",
71+
},
6772
&cli.BoolFlag{
6873
Name: "no-fetch",
6974
Usage: "Set this flag to prevent fetch of remote branches",
@@ -169,9 +174,10 @@ func runBackport(c *cli.Context) error {
169174
fmt.Printf("* Backporting %s to %s as %s\n", pr, localReleaseBranch, backportBranch)
170175

171176
sha := c.String("cherry-pick")
177+
accessToken := c.String("gh-access-token")
172178
if sha == "" {
173179
var err error
174-
sha, err = determineSHAforPR(ctx, pr)
180+
sha, err = determineSHAforPR(ctx, pr, accessToken)
175181
if err != nil {
176182
return err
177183
}
@@ -427,13 +433,16 @@ func readVersion() string {
427433
return strings.Join(split[:2], ".")
428434
}
429435

430-
func determineSHAforPR(ctx context.Context, prStr string) (string, error) {
436+
func determineSHAforPR(ctx context.Context, prStr, accessToken string) (string, error) {
431437
prNum, err := strconv.Atoi(prStr)
432438
if err != nil {
433439
return "", err
434440
}
435441

436442
client := github.NewClient(http.DefaultClient)
443+
if accessToken != "" {
444+
client = client.WithAuthToken(accessToken)
445+
}
437446

438447
pr, _, err := client.PullRequests.Get(ctx, "go-gitea", "gitea", prNum)
439448
if err != nil {

models/actions/artifact.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa
6969
OwnerID: t.OwnerID,
7070
CommitSHA: t.CommitSHA,
7171
Status: int64(ArtifactStatusUploadPending),
72-
ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + 3600*24*expiredDays),
72+
ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays),
7373
}
7474
if _, err := db.GetEngine(ctx).Insert(artifact); err != nil {
7575
return nil, err
@@ -78,6 +78,13 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa
7878
} else if err != nil {
7979
return nil, err
8080
}
81+
82+
if _, err := db.GetEngine(ctx).ID(artifact.ID).Cols("expired_unix").Update(&ActionArtifact{
83+
ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays),
84+
}); err != nil {
85+
return nil, err
86+
}
87+
8188
return artifact, nil
8289
}
8390

web_src/js/features/common-page.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ export function checkAppUrl() {
9191
showGlobalErrorMessage(`Your ROOT_URL in app.ini is "${appUrl}", it's unlikely matching the site you are visiting.
9292
Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification/OAuth2 sign-in.`, 'warning');
9393
}
94+
95+
export function checkAppUrlScheme() {
96+
const curUrl = window.location.href;
97+
// some users visit "http://domain" while appUrl is "https://domain", COOKIE_SECURE makes it impossible to sign in
98+
if (curUrl.startsWith('http:') && appUrl.startsWith('https:')) {
99+
showGlobalErrorMessage(`This instance is configured to run under HTTPS (by ROOT_URL config), you are accessing by HTTP. Mismatched scheme might cause problems for sign-in/sign-up.`, 'warning');
100+
}
101+
}

web_src/js/features/user-auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {checkAppUrl} from './common-page.ts';
1+
import {checkAppUrl, checkAppUrlScheme} from './common-page.ts';
2+
3+
export function initUserCheckAppUrl() {
4+
if (!document.querySelector('.page-content.user.signin, .page-content.user.signup, .page-content.user.link-account')) return;
5+
checkAppUrlScheme();
6+
}
27

38
export function initUserAuthOauth2() {
49
const outer = document.querySelector('#oauth2-login-navigator');

web_src/js/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {initFindFileInRepo} from './features/repo-findfile.ts';
2424
import {initCommentContent, initMarkupContent} from './markup/content.ts';
2525
import {initPdfViewer} from './render/pdf.ts';
2626

27-
import {initUserAuthOauth2} from './features/user-auth.ts';
27+
import {initUserAuthOauth2, initUserCheckAppUrl} from './features/user-auth.ts';
2828
import {
2929
initRepoIssueDue,
3030
initRepoIssueReferenceRepositorySearch,
@@ -219,6 +219,7 @@ onDomReady(() => {
219219
initCommitStatuses,
220220
initCaptcha,
221221

222+
initUserCheckAppUrl,
222223
initUserAuthOauth2,
223224
initUserAuthWebAuthn,
224225
initUserAuthWebAuthnRegister,

0 commit comments

Comments
 (0)