From 9dceaac6c65adcbc8ffd2db31291b8eb06e8d39c Mon Sep 17 00:00:00 2001
From: satotake <doublequotation@gmail.com>
Date: Thu, 21 Oct 2021 00:18:19 +0900
Subject: [PATCH] fix branch conditions

---
 src/git-command-manager.ts |  6 +++---
 src/input-helper.ts        | 12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts
index 6e3b4d2..5db9c3f 100644
--- a/src/git-command-manager.ts
+++ b/src/git-command-manager.ts
@@ -187,10 +187,10 @@ class GitCommandManager {
     }
 
     args.push('--prune', '--progress', '--no-recurse-submodules')
-    if (fetchDepth && fetchDepth > 0) {
-      args.push(`--depth=${fetchDepth}`)
-    } else if (shallowSince) {
+    if (shallowSince) {
       args.push(`--shallow-since=${shallowSince}`)
+    } else if (fetchDepth && fetchDepth > 0) {
+      args.push(`--depth=${fetchDepth}`)
     } else if (
       fshelper.fileExistsSync(
         path.join(this.workingDirectory, '.git', 'shallow')
diff --git a/src/input-helper.ts b/src/input-helper.ts
index b09e59c..ad9d2b1 100644
--- a/src/input-helper.ts
+++ b/src/input-helper.ts
@@ -81,6 +81,12 @@ export function getInputs(): IGitSourceSettings {
   result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
   core.debug(`clean = ${result.clean}`)
 
+  if (core.getInput('fetch-depth') && core.getInput('shallow-since')) {
+    throw new Error(
+      '`fetch-depth` and `shallow-since` cannot be used at the same time'
+    )
+  }
+
   // Fetch depth
   result.fetchDepth = Math.floor(Number(core.getInput('fetch-depth') || '1'))
   if (isNaN(result.fetchDepth) || result.fetchDepth < 0) {
@@ -92,12 +98,6 @@ export function getInputs(): IGitSourceSettings {
   result.shallowSince = core.getInput('shallow-since')
   core.debug(`shallow since = ${result.shallowSince}`)
 
-  if (result.fetchDepth > 0 && result.shallowSince) {
-    throw new Error(
-      '`fetch-depath` and `shallow-since` cannot be used at the same time'
-    )
-  }
-
   // LFS
   result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'
   core.debug(`lfs = ${result.lfs}`)