Browse Source

Add missing files, Add gitignore

pull/1/head
Jonas Franz 6 years ago
parent
commit
becfef8ebc
No known key found for this signature in database
GPG Key ID: 7293A220B7C38080
  1. 107
      .gitignore
  2. 37
      cmd/run.go
  3. 97
      config/config.go

107
.gitignore vendored

@ -0,0 +1,107 @@

# Created by https://www.gitignore.io/api/go,intellij
# Edit at https://www.gitignore.io/?templates=go,intellij

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

### Go Patch ###
/vendor/
/Godeps/

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# JetBrains templates
**___jb_tmp___

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

# End of https://www.gitignore.io/api/go,intellij

config.yml

37
cmd/run.go

@ -0,0 +1,37 @@
// staletea
// Copyright (C) 2019 Jonas Franz
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package cmd

import (
"gitea.com/jonasfranz/staletea/web"
"github.com/urfave/cli"
)

var CmdRun = cli.Command{
Action: run,
Name: "run",
Flags: []cli.Flag{
cli.StringFlag{
Name: "address",
Value: ":3030",
},
},
}

func run(ctx *cli.Context) error {
return web.StartServer(ctx.String("address"))
}

97
config/config.go

@ -0,0 +1,97 @@
// staletea
// Copyright (C) 2019 Jonas Franz
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package config

import (
"gitea.com/jonasfranz/staletea/utils"
"github.com/spf13/viper"
"os"
)

// Key represents a config key
type Key string

// Get the value of the key from config
func (k Key) Get() interface{} {
return viper.Get(string(k))
}

// Set the value of the key to config
func (k Key) Set(value interface{}) {
viper.Set(string(k), value)
}

func (k Key) setDefault(defaultValue interface{}) {
viper.SetDefault(string(k), defaultValue)
}

const (
DaysUntilStale Key = "daysUntilStale"
DaysUntilClose Key = "daysUntilClose"
LabelBlacklist Key = "onlyLabels"
LabelWhitelist Key = "exemptLabels"
StaleLabel Key = "staleLabel"

MarkComment Key = "markComment"
UnmarkComment Key = "unmarkComment"
CloseComment Key = "closeComment"

TypeBlacklist Key = "only"

BaseURL Key = "host"

GiteaURL Key = "gitea.url"
GiteaClientID Key = "gitea.client_id"
GiteaClientSecret Key = "gitea.client_secret"

SessionSecret Key = "session_secret"
)

func SetupConfig() error {
DaysUntilStale.setDefault(60)
DaysUntilClose.setDefault(7)
LabelBlacklist.setDefault([]string{})
LabelWhitelist.setDefault([]string{})
StaleLabel.setDefault("wontfix")

MarkComment.setDefault(`This issue has been automatically marked as stale because it has not had
recent activity. It will be closed in %d days if no further activity occurs. Thank you
for your contributions.`)
UnmarkComment.setDefault("")
CloseComment.setDefault("This issue was closed automatically since it was marked as stale and had no recent activity.")
TypeBlacklist.setDefault([]string{})
BaseURL.setDefault("http://localhost")
GiteaURL.setDefault("https://gitea.com")
GiteaClientID.setDefault("")
GiteaClientSecret.setDefault("")

secret, err := utils.NewSecret(32)
if err != nil {
return err
}
SessionSecret.setDefault(secret)

viper.SetConfigName("config")
viper.SetConfigType("yml")
viper.AddConfigPath(".")
if err := viper.SafeWriteConfigAs("config.yml"); err != nil {
if os.IsNotExist(err) {
err = viper.WriteConfigAs("config.yml")
}
}
return viper.ReadInConfig()
}
Loading…
Cancel
Save