summaryrefslogtreecommitdiffstats
path: root/modules/util
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-10-26 23:10:54 -0700
committerLauris BH <lauris@nix.lv>2017-10-27 09:10:54 +0300
commit5866eb23217de4d29b181e30c26cee28ebc6aedc (patch)
treef8f67462544c709e8dd6988ca4d55a22cfc3a22c /modules/util
parent762f1d7237de5727815ebda9593f7f9a20a5a077 (diff)
downloadgitea-5866eb23217de4d29b181e30c26cee28ebc6aedc.tar.gz
gitea-5866eb23217de4d29b181e30c26cee28ebc6aedc.zip
Code/repo search (#2582)
Indexed search of repository contents (for default branch only)
Diffstat (limited to 'modules/util')
-rw-r--r--modules/util/path.go16
-rw-r--r--modules/util/util.go16
2 files changed, 32 insertions, 0 deletions
diff --git a/modules/util/path.go b/modules/util/path.go
new file mode 100644
index 0000000000..f79334209c
--- /dev/null
+++ b/modules/util/path.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package util
+
+import "path/filepath"
+
+// EnsureAbsolutePath ensure that a path is absolute, making it
+// relative to absoluteBase if necessary
+func EnsureAbsolutePath(path string, absoluteBase string) string {
+ if filepath.IsAbs(path) {
+ return path
+ }
+ return filepath.Join(absoluteBase, path)
+}
diff --git a/modules/util/util.go b/modules/util/util.go
index 104c80f524..e99f951f21 100644
--- a/modules/util/util.go
+++ b/modules/util/util.go
@@ -38,3 +38,19 @@ func OptionalBoolOf(b bool) OptionalBool {
}
return OptionalBoolFalse
}
+
+// Max max of two ints
+func Max(a, b int) int {
+ if a < b {
+ return b
+ }
+ return a
+}
+
+// Min min of two ints
+func Min(a, b int) int {
+ if a > b {
+ return b
+ }
+ return a
+}