mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	handle initial commit for compareUrl
This commit is contained in:
		@@ -226,7 +226,11 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
 | 
						repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
 | 
				
			||||||
	compareUrl := fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
 | 
						compareUrl := ""
 | 
				
			||||||
 | 
						// if not the first commit, set the compareUrl
 | 
				
			||||||
 | 
						if !strings.HasPrefix(oldCommitId, "0000000") {
 | 
				
			||||||
 | 
							compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	commits := make([]*PayloadCommit, len(commit.Commits))
 | 
						commits := make([]*PayloadCommit, len(commit.Commits))
 | 
				
			||||||
	for i, cmt := range commit.Commits {
 | 
						for i, cmt := range commit.Commits {
 | 
				
			||||||
		commits[i] = &PayloadCommit{
 | 
							commits[i] = &PayloadCommit{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,9 +72,14 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if len(p.Commits) == 1 {
 | 
						if len(p.Commits) == 1 {
 | 
				
			||||||
		commitString = "1 new commit"
 | 
							commitString = "1 new commit"
 | 
				
			||||||
 | 
							if p.CompareUrl != "" {
 | 
				
			||||||
 | 
								commitString = SlackLinkFormatter(p.CompareUrl, commitString)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		commitString = fmt.Sprintf("%d new commits", len(p.Commits))
 | 
							commitString = fmt.Sprintf("%d new commits", len(p.Commits))
 | 
				
			||||||
		commitString = SlackLinkFormatter(p.CompareUrl, commitString)
 | 
							if p.CompareUrl != "" {
 | 
				
			||||||
 | 
								commitString = SlackLinkFormatter(p.CompareUrl, commitString)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name)
 | 
						repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user