internal/store/commitrefs.go

b7fc5924eece9dee015ea517faf7c52fe4f171af
gitbay/internal/store/commitrefs.go history · blame · raw

15 lines · 497 bytes

 1package store
 2
 3// TryRecordCommitRef marks a commit as having referenced an issue. It
 4// reports whether this pair was new — false means the reference was
 5// already processed and must not act again.
 6func (s *Store) TryRecordCommitRef(issueID int64, sha string) (bool, error) {
 7	res, err := s.DB.Exec(
 8		"INSERT INTO issue_commit_refs (issue_id, sha) VALUES (?, ?) ON CONFLICT DO NOTHING",
 9		issueID, sha)
10	if err != nil {
11		return false, err
12	}
13	n, _ := res.RowsAffected()
14	return n > 0, nil
15}