Commit Graph

17 Commits

Author SHA1 Message Date
nitrocode
82cf170d8f Ignore gpg signing for tests (#2296) 2022-06-05 20:06:24 -07:00
Aiden Scandella
8bc3c087bc fix: working dir tests initial branch assumes "master" (#2264)
This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".

For example, if you run:

```sh
git config --global init.defaultBranch main
```

And then run these tests, you get:

```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
    working_dir_test.go:71: err running "git checkout master": error:
    pathspec 'master' did not match any file(s) known to git

    --- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
        working_dir_test.go:127: err running "git checkout master":
        error: pathspec 'master' did not match any file(s) known to git

        --- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
            logger.go:130: 2022-05-17T10:05:33.665-0700 INFO    creating
            dir "/tmp/3762936464/repos/0/default"
                working_dir_test.go:198: unexpected error: running git
                clone --branch master --single-branch
                file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
                Cloning into '/tmp/3762936464/repos/0/default'...
                        warning: Could not find remote branch master to
                        clone.
                                fatal: Remote branch master not found in
                                upstream origin
                                        : exit status 128
                                        --- FAIL:
                                        TestClone_CheckoutMergeConflict
                                        (0.68s)
      working_dir_test.go:232: err running "git checkout master": error:
      pathspec 'master' did not match any file(s) known to git

      --- FAIL: TestClone_MasterHasDiverged (0.68s)
          working_dir_test.go:344: err running "git clone --branch
          master --single-branch /tmp/1931262087 .": Cloning into '.'...
                  warning: Could not find remote branch master to clone.
                          fatal: Remote branch master not found in
                          upstream origin

                          --- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
      working_dir_test.go:415: err running "git clone --branch master
      --single-branch /tmp/2356723317 .": Cloning into '.'...
              warning: Could not find remote branch master to clone.
                      fatal: Remote branch master not found in upstream
                      origin

                      FAIL
                      FAIL
                      github.com/runatlantis/atlantis/server/events
                      7.269s
                      FAIL
```
2022-05-17 10:55:02 -07:00
PePe Amengual
485c4b508f Revert "fix: add path to WorkingDir methods (#2180)" (#2253)
This reverts commit 1a8344489f.
2022-05-13 10:19:29 -07:00
KevinSnyderCodes
1a8344489f fix: add path to WorkingDir methods (#2180)
* fix: add path to WorkingDir methods

`WorkingDirLocker` and `WorkingDir` are closely related -- the former acquires a lock, which ensures that the latter can safely operate on a given file path.

In #2131 we added `path` to the `WorkingDirLocker` lock key, but neglected to add the same to `WorkingDir`.

This commit adds `path` as an argument to certain `WorkingDir` methods, and includes `path` in the directory that we use to clone the repository for a given project.

Since `path` can include certain special characters such as `/`, we encode `path` as base32 when using it as part of a file path. This should ensure no special characters are used in the filesystem, and that the value can be decoded if desired (unlike hashes such as md5).

Additional changes:

- All calls to changed methods have been updated, including unit tests
- Mocks have been regenerated for `WorkingDir` and `WorkingDirLocker`
- `working_dir_test.go`
  - Commands that operate on filesystem paths have been updated to include the base32 encoded `path` value
  - When running `git init`, we include `-b master` as additional arguments, to ensure that `master` is our default branch (expected by the unit tests)

* Try fixing E2E tests

* Fix DefaultPendingPlanFinder

In addition to iterating over `workspaceDirs`, also iterate over `pathDirs`, and use both `workspace` and `path` to build `repoDir`.

* Fix DefaultPendingPlanFinder unit tests

* Fix DefaultProjectCommandBuilder unit tests

Co-authored-by: Kevin Snyder <kevinsnyder@KevinSnydersMBP.lan>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-1-188.ec2.internal>
2022-04-08 11:55:35 -07:00
Paul Calley
6b50e84ab9 Add undiverged apply requirement (#1587)
* ORCA-731 Force PR authors to rebase if master has diverged (#70)

* initial commit for undiverge apply req

* Update documentation

* Fix existing unit tests

* HasDiverged unit test

* project command runner unit test

* Global config tests cases

* update parser unit tests

* Update project_test unit tests

* Fix linting

* fix test case with logging output

* add space on readme markdown

* Remove unused variable

* remove deprecated flag option

* Use global args struct instead of passing in args

* Fix merge issue
2021-06-03 14:35:30 -07:00
Nish Krishnan
7ac8106f8a Add structured logger (#54) (#1467)
This is two changes:

Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward
Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
2021-04-06 12:02:25 -07:00
Nish Krishnan
1110c526c5 Ensure that refreshed creds are used to update remote. 2020-10-23 20:06:09 -07:00
Nish Krishnan
0a7d6441fd lint. 2020-10-14 17:41:37 -07:00
Nish Krishnan
9fa0c91bcb [1193] Fix merge strategy for gh apps 2020-10-14 17:35:38 -07:00
Luke Kysow
875abf1362 Refactoring to github app code
- rename gh-app-key to gh-app-key-file for clarity
- change git credentials writer to append a line if there is an existing
.git-credentials file and in the case of the github app to replace the
old github app line
- removed automatically setting --write-git-creds to true when using a
github app and instead requiring this is set specifically
2020-06-19 11:41:44 -07:00
rob
011d3f8229 Test against a live repo, fix accordingly
more docs, add installation step
2020-06-03 20:25:11 -04:00
rob
227ce9cbf4 Upgrade to github/v31 for CompleteAppManifest
split fixtures out elsewhere, add working dir test
2020-06-03 20:18:13 -04:00
Luke Kysow
889d584514 Refactor branch diverged warning.
- only check for divergence if using checkout strategy merge
2019-11-27 10:52:39 -08:00
Marco Rinalducci
a824ad4d23 Detects if master branch has diverged and warn to pull new commits in comment 2019-11-27 10:52:39 -08:00
Steve Mitchell
17bcd9d768 fix a picky test that depends on git version 2019-09-18 22:56:09 -04:00
Luke Kysow
93cd6a5431 Never use fast-forward merges
When using --checkout-strategy merge, we were performing the merge
without the --no-ff flag. This meant that if the branch could be merged
via a fast-forward merge (without a merge commit), then later when we
ran git rev-parse HEAD^2 to determine if the repo was at the right
commit, it would fail.

Now we merge with --no-ff which ensures the commit tree will always look
the same and git rev-parse HEAD^2 will always succeed.
2019-04-10 15:12:32 -03:00
Luke Kysow
16a4946bea Test new checkout logic. 2019-01-16 18:32:02 -05:00