Comments (19)
@mrtind please, have a look and share any comments or questions that you may have
from derek.
@mrtind
apparently milestones are slightly different.
first you have to enumerate them:
https://github.com/google/go-github/blob/master/github/issues_milestones.go
using ListMilestones
, which will return a list of Milestone
objects. important elements are Title
and Number
.
so if the user types:
Derek set milestone: 4.8
we need to use ListMilestones
to find the Number
of that milestone with Title
== 4.8
.
once you know the number you can add this milestone to an issue using Edit
for an issue:
https://github.com/google/go-github/blob/master/github/issues.go#L288
and an IssueRequest
object.
the IssueRequest
object has a Milestone
field, for example:
input := &IssueRequest{
Milestone: github.Int(1)
}
would set the milestone fro that issue to Number = 1
.
to remove a milestone from an issue (Derek remove milestone: 4.8
), the same applies, but instead of an actual Number
i think you have to pass nil
or Int(0)
to unset a milestone from an issue. go-github
uses an int pointer for this.
input := &IssueRequest{
Milestone: nil // or github.Int(0)
}
and here is how you use Edit
:
https://github.com/google/go-github/blob/master/github/issues_test.go#L235
the go-github
library does not have unit tests for this, so not sure how well it's tested and supported.
let me know of further questions, thanks.
from derek.
@mrtind
i was about to comment further here, but i see that you've already submitted a PR.
nice! progressing fast! :)
from derek.
Thanks @mrtind - great work!
from derek.
Hello! I saw that AddLabelsToIssue() function is used to apply labels, but Milestones does not support analogous function, it does however have CreateMilestone() but Labels also have function CreateLabels() and its not used. I was wondering is CreateMilestone() function enough to apply milestone or I should try to create my own AddMilestonesToIssue() function?
from derek.
Hi @mrtind Thanks for looking into this.
What struct/object does "CreateMilestone" live on?
I would think we are not creating milestones here, but adding them to existing issues or PRs. This may need you to call something like "update issue" rather than AddMilestoneToIssue().
from derek.
It lives on IssuesService the same for AddLabelsToIssue(). Also i notices there is EditMilestone() function i will try to use that.
from derek.
Thanks @neolit123 for pointing this out, apparently I was heading in the wrong direction...
from derek.
Great analysis @neolit123 that is really helpful and detailed.
Martin, I would suggest trying this out in an isolated example/repo to see if it works - or hard-coding it into Derek and testing it on your DigitalOcean instance so that you can get some confidence before proceeding.
Alex
from derek.
Yeah that I managed to set label in own repo with derek. Now i must find a way to remove it and create tests.
from derek.
Does the example from Lubomir help of setting the value to 0/nil?
from derek.
When i manually remove milestone i see the webhook "milestone":null, ... but when i set milestone *int to nil it does not solve the issue. I will try again obviously the milestone field must be null i must find a way to set it to null.
from derek.
@mrtind
i predicted, nil
or 0
would not work. see:
google/go-github#236
we have to do a workaround. ^ there is a proposed solution in there to use a PATCH
request directly.
https://developer.github.com/v3/?#http-verbs
A PATCH request may accept one or more of the attributes to update the resource
the function calls in the workaround are here:
https://github.com/google/go-github/blob/master/github/github.go#L295
https://github.com/google/go-github/blob/master/github/github.go#L455 (note that this needs Context e.g. context.Background())
so the idea is to basically PATCH out the milestone JSON from the issue JSON.
from derek.
I believe that one of the examples suggested using a custom struct, would that work?
from derek.
do you mean a custom struct instead of the anonymous struct in the workaround?
from derek.
@alexellis @neolit123 I managed to remove the label with the workaround but the patch of code looks ugly. Should i make a function instead of that block of code ?
from derek.
hard to say without seeing your code. better wait before it's made into a PR.
from derek.
Hi all, I'd like to let you know that the PR raised by @mrtind has been merged and released, thanks to everyone who helped on this feature.
Derek is now live and I've started setting up some milestones for Derek features & tweaks. Great job Martin!
Alex
from derek.
Derek close: released
from derek.
Related Issues (20)
- Pull Derek's watchdog binary via multi-stage build HOT 1
- Run Derek container as non-root user HOT 4
- Publishing Docker images is broken HOT 4
- Have Derek add commits as well as PRs closed in each release note HOT 1
- Add 1 min safety window for commit listing HOT 2
- Derek marks PR with `no-dco` but the commit is signed HOT 1
- Proposal: Label and message for PRs with Merge Commits HOT 2
- Add Derek to two new organizations (vielmetti, tinkerbell) HOT 3
- Feature request: give multiple commands within a single comment HOT 2
- [Bug] Regression in authentication code HOT 4
- Inconsistent fetching of commits HOT 4
- Switch to using go modules HOT 3
- Proposal: Detect Hacktoberfest PRs without requiring commit sign-off HOT 7
- Suggestion: make this project more visible HOT 3
- Crash generating release notes HOT 1
- Detect repository default branch HOT 4
- Migrate to GitHub Actions HOT 3
- Have Derek show a link for changes between releases on auto-generated release notes. HOT 3
- Validate HMAC with SHA256
- Exclude pre-releases from release notes HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from derek.