mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Display the branch name in the commit view (#5950)
* add branch info * Remove blank lines * Remove blank lines * update git dependency
This commit is contained in:
		
							
								
								
									
										4
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							| @@ -3,11 +3,11 @@ | |||||||
|  |  | ||||||
| [[projects]] | [[projects]] | ||||||
|   branch = "master" |   branch = "master" | ||||||
|   digest = "1:8a6c3c311918c0f08fa2899feae2c938a9bf22b51378e3720d63b80aca4e80aa" |   digest = "1:537ed734fb4869453583d9ce24d93bf68c88287082778efe55ae749970a1012a" | ||||||
|   name = "code.gitea.io/git" |   name = "code.gitea.io/git" | ||||||
|   packages = ["."] |   packages = ["."] | ||||||
|   pruneopts = "NUT" |   pruneopts = "NUT" | ||||||
|   revision = "d04f81a6f8979be39da165fc034447a805071b97" |   revision = "fbe468c7a634991285eaa1f93e73431e3edfc471" | ||||||
|  |  | ||||||
| [[projects]] | [[projects]] | ||||||
|   branch = "master" |   branch = "master" | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ | |||||||
| 				{{if IsMultilineCommitMessage .Commit.Message}} | 				{{if IsMultilineCommitMessage .Commit.Message}} | ||||||
| 					<pre class="commit-body">{{RenderCommitBody .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre> | 					<pre class="commit-body">{{RenderCommitBody .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre> | ||||||
| 				{{end}} | 				{{end}} | ||||||
|  | 				<span class="text grey"><i class="octicon octicon-git-branch"></i>{{.Commit.Branch}}</span> | ||||||
| 			</div> | 			</div> | ||||||
| 			<div class="ui attached info segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}"> | 			<div class="ui attached info segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}"> | ||||||
| 				<div class="ui stackable grid"> | 				<div class="ui stackable grid"> | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								vendor/code.gitea.io/git/commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/code.gitea.io/git/commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -18,6 +18,7 @@ import ( | |||||||
|  |  | ||||||
| // Commit represents a git commit. | // Commit represents a git commit. | ||||||
| type Commit struct { | type Commit struct { | ||||||
|  | 	Branch string // Branch this commit belongs to | ||||||
| 	Tree | 	Tree | ||||||
| 	ID            SHA1 // The ID of this commit object | 	ID            SHA1 // The ID of this commit object | ||||||
| 	Author        *Signature | 	Author        *Signature | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								vendor/code.gitea.io/git/repo_commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/code.gitea.io/git/repo_commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -10,7 +10,7 @@ import ( | |||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/mcuadros/go-version" | 	version "github.com/mcuadros/go-version" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // GetRefCommitID returns the last commit ID string of given reference (branch or tag). | // GetRefCommitID returns the last commit ID string of given reference (branch or tag). | ||||||
| @@ -130,6 +130,14 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) { | |||||||
| 	commit.repo = repo | 	commit.repo = repo | ||||||
| 	commit.ID = id | 	commit.ID = id | ||||||
|  |  | ||||||
|  | 	data, err = NewCommand("name-rev", id.String()).RunInDirBytes(repo.Path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// name-rev commitID ouput will be "COMMIT_ID master" or "COMMIT_ID master~12" | ||||||
|  | 	commit.Branch = strings.Split(strings.Split(string(data), " ")[1], "~")[0] | ||||||
|  |  | ||||||
| 	repo.commitCache.Set(id.String(), commit) | 	repo.commitCache.Set(id.String(), commit) | ||||||
| 	return commit, nil | 	return commit, nil | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user