Skip to content

Commit

Permalink
Merge pull request #114 from ritsec/43-add-config-value-for-which-bra…
Browse files Browse the repository at this point in the history
…nch-to-pull-updates-for-update

debugging
  • Loading branch information
c0untingNumbers committed May 10, 2024
2 parents 96a0a59 + c4d0c87 commit 6e47a70
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions commands/slash/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@ func Update() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc
)
defer span.Finish()

logging.Debug(s, "Update command received", i.Member.User, span)

force := false
branch := "main"
if len(i.ApplicationCommandData().Options) != 0 {
force = i.ApplicationCommandData().Options[0].BoolValue()
branch = i.ApplicationCommandData().Options[1].StringValue()
}

debugMessage := fmt.Sprintf("Update command received with options: force=%v, branch=%s", force, branch)
logging.Debug(s, debugMessage, i.Member.User, span)

var update bool
var err error

if branch == "main" {
logging.Debug(s, "Following the Main branch update flow", i.Member.User, span)
update, err = helpers.UpdateMainBranch()
if err != nil {
logging.Error(s, "Error updating main branch", i.Member.User, span, logrus.Fields{"err": err.Error()})
Expand All @@ -60,7 +62,8 @@ func Update() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc
// Soft lock the main server to main branch
// TODO change the id to main server id before merging
if i.GuildID == "1073013590702964856" {
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
logging.Warning(s, "Branch config option used with /update", i.Member.User, span)
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Cannot use the branch config option on the main server",
Expand Down

0 comments on commit 6e47a70

Please sign in to comment.