New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing issues through commits #302
Comments
Aha, thanks all your previous PRs!
Commits are not saved in database, the only time you can reach if the commit message contains somethings like |
My thought was, that there is a CommitId field on the Commit struct, but it always gets 0. How is it intended to be used? I though I could create a comment with CommitId referencing the commit that contains the Update: My idea is to change the CommitId of the Comment struct to a String and then save a commit hash in it. This way we could link to the commit. If pull requests get implemented, the field can then act as either a reference to a commit in the pull request or as closing commit. (This could depend on the Type of the comment) |
|
It was just an thought :-) I could use the Content of the comment, for the commit message, but I would also need to store the commit hash somehow.It was just an thought :-) I could use the Content of the comment, for the commit message, but I would still also need to store the commit hash somewhere. |
Add a refType field to distinguish? |
I see two ways to solve this: Solution 1: We could use your suggestion and add a ReferenceType type, which could look like this: type ReferenceType int
const (
// Reference from some pull request
PULL ReferenceType = iota + 1
// Reference from another issue
ISSUE
// Plain old comment
COMMENT
// Reference from some commit (not part of a pull request)
COMMIT
) Solution 2: We could just combine the ReferenceType with the existing IT_* types (used as Comment.Type values) like this (see comments): type CommentType int
const (
// We use iota and the order COMMENT, REOPEN, CLOSE to maintain
// backwards compatibility with existing comments, without updating them
// Plain old comment, can be associated with a commit (CommitId > 0) and a line (Line > 0)
COMMENT CommentType = iota
// Reopen action
REOPEN
// Close action
CLOSE
// Reference from another issue
// Maybe with some prefix/suffix to show that it's a reference,
// like ISSUEREF or something similar
ISSUE
// Reference from some commit (not part of a pull request)
COMMIT
// Reference from some pull request
PULL
) Personally I like the 2. one more, because it only needs one type, and maintains backwards compatibility, without having to update anything. (Except I'm missing something) One thing I'm still not sure how to implement is the case when a normal commit references (closes) an issue. In this case we need 1. the commit message (to be shown on the issue page) and it's hash (so that we can link to it). The message can be saved inside the normal Comment.Content field, which is otherwise only used by normal comments. Now the hash has to be saved somewhere too. It could be put in the Comment.Content field too, but I would rather have it stored in another column or table. |
Just make a ISSUE_COMMENT in CommentType should be fine? |
My problem is not the type. Comment {
// ...
Type: <ISSUE, COMMIT or PULL>
Content: <COMMIT MESSAGE>
// ...
} but the commit hash must be stored too I thought about putting it directly into the message ( |
If we don't need access that commit hash anywhere else, then store in message is fine. |
I've made a pull request to test/review my changes: #305 |
Fix #302. Show referencing commits in issue.
Sorry, how does code work? |
I tried to push commit with message |
I just tested it with my local branch (the one merged) and the current gogits/gogs dev branch. This is what I did in both cases (not exactly the same thing): And this is what i got on the current dev branch: I get the same with my local branch. It searches for the same words as Github. (https://help.github.com/articles/closing-issues-via-commit-messages) followed by the issue as either |
so wried ... |
Hey, have you tested it again? |
I'll test again later and look at the code. |
Sorry for late, it's working! |
No problem :-) |
Reference: https://trello.com/c/xGlRil52/241-git-push-commit
Being bored I looked into this feature request and created a first working version (currently in my fork nuss-justin/gogs@469cbc881340dd).
This also fixes a little bug I introduced, where the completeness of a milestone wouldn't get updated if an issue gets closed/reopened.
The next thing I wanted to do is adding a closing comment to issues, closed through commits.
Now I stumbled across the comments Table which has a commit_id field, but it seems like commits aren't implemented yet. At least I wasn't able to find out what the commit_id references.
Now my little question:
What's the state of commits in the database?
The text was updated successfully, but these errors were encountered: