Coder Social home page Coder Social logo

Comments (19)

neolit123 avatar neolit123 commented on June 6, 2024 1

@mrtind please, have a look and share any comments or questions that you may have 👍

from derek.

neolit123 avatar neolit123 commented on June 6, 2024 1

@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.

neolit123 avatar neolit123 commented on June 6, 2024 1

@mrtind
i was about to comment further here, but i see that you've already submitted a PR.
nice! progressing fast! :)

from derek.

dirkhh avatar dirkhh commented on June 6, 2024 1

Thanks @mrtind - great work!

from derek.

martindekov avatar martindekov commented on June 6, 2024

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.

alexellis avatar alexellis commented on June 6, 2024

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.

martindekov avatar martindekov commented on June 6, 2024

It lives on IssuesService the same for AddLabelsToIssue(). Also i notices there is EditMilestone() function i will try to use that.

from derek.

martindekov avatar martindekov commented on June 6, 2024

Thanks @neolit123 for pointing this out, apparently I was heading in the wrong direction...

from derek.

alexellis avatar alexellis commented on June 6, 2024

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.

martindekov avatar martindekov commented on June 6, 2024

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.

alexellis avatar alexellis commented on June 6, 2024

Does the example from Lubomir help of setting the value to 0/nil?

from derek.

martindekov avatar martindekov commented on June 6, 2024

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.

neolit123 avatar neolit123 commented on June 6, 2024

@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.

alexellis avatar alexellis commented on June 6, 2024

I believe that one of the examples suggested using a custom struct, would that work?

from derek.

neolit123 avatar neolit123 commented on June 6, 2024

do you mean a custom struct instead of the anonymous struct in the workaround?

from derek.

martindekov avatar martindekov commented on June 6, 2024

@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.

neolit123 avatar neolit123 commented on June 6, 2024

hard to say without seeing your code. better wait before it's made into a PR.

from derek.

alexellis avatar alexellis commented on June 6, 2024

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.

alexellis avatar alexellis commented on June 6, 2024

Derek close: released 🎉

from derek.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.