-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into punit/Showing-archive-label-issue-filter
- Loading branch information
Showing
37 changed files
with
593 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
date: "2023-08-14T00:00:00+00:00" | ||
title: "Blame File View" | ||
slug: "blame" | ||
sidebar_position: 13 | ||
toc: false | ||
draft: false | ||
aliases: | ||
- /en-us/blame | ||
menu: | ||
sidebar: | ||
parent: "usage" | ||
name: "Blame" | ||
sidebar_position: 13 | ||
identifier: "blame" | ||
--- | ||
|
||
# Blame File View | ||
|
||
Gitea supports viewing the line-by-line revision history for a file also known as blame view. | ||
You can also use [`git blame`](https://git-scm.com/docs/git-blame) on the command line to view the revision history of lines within a file. | ||
|
||
1. Navigate to and open the file whose line history you want to view. | ||
1. Click the `Blame` button in the file header bar. | ||
1. The new view shows the line-by-line revision history for a file with author and commit information on the left side. | ||
1. To navigate to an older commit, click the ![versions](/octicon-versions.svg) icon. | ||
|
||
## Ignore commits in the blame view | ||
|
||
All revisions specified in the `.git-blame-ignore-revs` file are hidden from the blame view. | ||
This is especially useful to hide reformatting changes and keep the benefits of `git blame`. | ||
Lines that were changed or added by an ignored commit will be blamed on the previous commit that changed that line or nearby lines. | ||
The `.git-blame-ignore-revs` file must be located in the root directory of the repository. | ||
For more information like the file format, see [the `git blame --ignore-revs-file` documentation](https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt). | ||
|
||
### Bypassing `.git-blame-ignore-revs` in the blame view | ||
|
||
If the blame view for a file shows a message about ignored revisions, you can see the normal blame view by appending the url parameter `?bypass-blame-ignore=true`. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package v1_21 //nolint | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
|
||
"code.gitea.io/gitea/modules/git" | ||
giturl "code.gitea.io/gitea/modules/git/url" | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"xorm.io/xorm" | ||
) | ||
|
||
func AddRemoteAddressToMirrors(x *xorm.Engine) error { | ||
type Mirror struct { | ||
RemoteAddress string `xorm:"VARCHAR(2048)"` | ||
} | ||
|
||
type PushMirror struct { | ||
RemoteAddress string `xorm:"VARCHAR(2048)"` | ||
} | ||
|
||
if err := x.Sync(new(Mirror), new(PushMirror)); err != nil { | ||
return err | ||
} | ||
|
||
if err := migratePullMirrors(x); err != nil { | ||
return err | ||
} | ||
|
||
return migratePushMirrors(x) | ||
} | ||
|
||
func migratePullMirrors(x *xorm.Engine) error { | ||
type Mirror struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
RepoID int64 `xorm:"INDEX"` | ||
RemoteAddress string `xorm:"VARCHAR(2048)"` | ||
} | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
|
||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
|
||
limit := setting.Database.IterateBufferSize | ||
if limit <= 0 { | ||
limit = 50 | ||
} | ||
|
||
start := 0 | ||
|
||
for { | ||
var mirrors []Mirror | ||
if err := sess.Limit(limit, start).Find(&mirrors); err != nil { | ||
return err | ||
} | ||
|
||
if len(mirrors) == 0 { | ||
break | ||
} | ||
start += len(mirrors) | ||
|
||
for _, m := range mirrors { | ||
remoteAddress, err := getRemoteAddress(sess, m.RepoID, "origin") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
m.RemoteAddress = remoteAddress | ||
|
||
if _, err = sess.ID(m.ID).Cols("remote_address").Update(m); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if start%1000 == 0 { // avoid a too big transaction | ||
if err := sess.Commit(); err != nil { | ||
return err | ||
} | ||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return sess.Commit() | ||
} | ||
|
||
func migratePushMirrors(x *xorm.Engine) error { | ||
type PushMirror struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
RepoID int64 `xorm:"INDEX"` | ||
RemoteName string | ||
RemoteAddress string `xorm:"VARCHAR(2048)"` | ||
} | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
|
||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
|
||
limit := setting.Database.IterateBufferSize | ||
if limit <= 0 { | ||
limit = 50 | ||
} | ||
|
||
start := 0 | ||
|
||
for { | ||
var mirrors []PushMirror | ||
if err := sess.Limit(limit, start).Find(&mirrors); err != nil { | ||
return err | ||
} | ||
|
||
if len(mirrors) == 0 { | ||
break | ||
} | ||
start += len(mirrors) | ||
|
||
for _, m := range mirrors { | ||
remoteAddress, err := getRemoteAddress(sess, m.RepoID, m.RemoteName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
m.RemoteAddress = remoteAddress | ||
|
||
if _, err = sess.ID(m.ID).Cols("remote_address").Update(m); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if start%1000 == 0 { // avoid a too big transaction | ||
if err := sess.Commit(); err != nil { | ||
return err | ||
} | ||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return sess.Commit() | ||
} | ||
|
||
func getRemoteAddress(sess *xorm.Session, repoID int64, remoteName string) (string, error) { | ||
var ownerName string | ||
var repoName string | ||
has, err := sess. | ||
Table("repository"). | ||
Cols("owner_name", "lower_name"). | ||
Where("id=?", repoID). | ||
Get(&ownerName, &repoName) | ||
if err != nil { | ||
return "", err | ||
} else if !has { | ||
return "", fmt.Errorf("repository [%v] not found", repoID) | ||
} | ||
|
||
repoPath := filepath.Join(setting.RepoRootPath, strings.ToLower(ownerName), strings.ToLower(repoName)+".git") | ||
|
||
remoteURL, err := git.GetRemoteAddress(context.Background(), repoPath, remoteName) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
u, err := giturl.Parse(remoteURL) | ||
if err != nil { | ||
return "", err | ||
} | ||
u.User = nil | ||
|
||
return u.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.