Skip to content

Commit

Permalink
Merge pull request #55 from Tinder/fix_config_init_bug
Browse files Browse the repository at this point in the history
Fix Bug Where GitQuery Init was looking at latest of branch instead o…
  • Loading branch information
tinder-aminghadersohi authored Mar 4, 2021
2 parents cc1dc10 + 4e45321 commit 2776f2b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions core/src/main/kotlin/com/tinder/gitquery/core/GitQueryInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ object GitQueryInit {

val actualRepoDirectory = config.getActualRepoPath(buildDir)

prepareRepo(config.remote, config.branch, actualRepoDirectory, verbose = verbose)

val initConfig = config.initConfig

prepareRepo(
config.remote,
if (initConfig.revision.isEmpty()) config.branch else initConfig.revision,
actualRepoDirectory,
verbose = verbose
)

config.files = initFiles(
includeGlobs = initConfig.includeGlobs,
excludeGlobs = initConfig.excludeGlobs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package com.tinder.gitquery.core
* This file was generated by ./build-support/bin/write-version-class
*/

const val GIT_QUERY_VERSION = "3.0.6"
const val GIT_QUERY_VERSION = "3.0.7"
10 changes: 5 additions & 5 deletions core/src/main/kotlin/com/tinder/gitquery/core/utils/RepoUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal fun prepareRepo(remote: String, branch: String, repoDir: String, verbos
// In cases where the branch changes, `git checkout $branch` will fail silently, prompting
// us to do a clean single branch clone of the repository.
exitCode = sh(
verbose = verbose,
verbose,
"cd $repoDir && git checkout $branch &>/dev/null && git pull origin $branch --tags"
)
}
Expand All @@ -35,8 +35,8 @@ internal fun prepareRepo(remote: String, branch: String, repoDir: String, verbos
// 2) or, we couldn't pull the branch that we wanted.
// Cleanup and try a fresh clone.
if (exitCode != 0 || !repoExists) {
sh(verbose = verbose, "rm -rf $repoDir")
exitCode = sh(verbose = verbose, "git clone --single-branch -b $branch $remote $repoDir")
sh(verbose, "rm -rf $repoDir")
exitCode = sh(verbose, "git clone --single-branch -b $branch $remote $repoDir")
}

check(exitCode == 0) { "Error cloning/updating repo $remote into directory $repoDir" }
Expand All @@ -46,12 +46,12 @@ internal fun prepareRepo(remote: String, branch: String, repoDir: String, verbos
* Get current revision of the repoDir.
*/
internal fun repoHeadRevision(repoDir: String, verbose: Boolean): String {
return shellResult(verbose = verbose, "(cd $repoDir && git rev-parse HEAD)")
return shellResult(verbose, "(cd $repoDir && git rev-parse HEAD)")
}

/**
* Checks the existence of the repoDir
*/
internal fun repoExists(repoDir: String, verbose: Boolean): Boolean {
return 0 == sh(verbose = verbose, "[ -d $repoDir ] && [ -d $repoDir/.git ]")
return 0 == sh(verbose, "[ -d $repoDir ] && [ -d $repoDir/.git ]")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.daemon=true
org.gradle.parallel=true

GROUP=com.tinder.gitquery
VERSION_NAME=3.0.6
VERSION_NAME=3.0.7

POM_DESCRIPTION=A library for querying and syncing files in a remote git repo.
POM_URL=https://github.com/Tinder/GitQuery
Expand Down

0 comments on commit 2776f2b

Please sign in to comment.