-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from marcellodesales/develop
Tested Release
- Loading branch information
Showing
19 changed files
with
527 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# https://github.com/golangci/golangci-lint-action#how-to-use | ||
name: lint-develop | ||
|
||
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-a-list-of-events | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: Code Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v1 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | ||
version: v1.31 | ||
|
||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
|
||
# Optional: golangci-lint command line arguments. | ||
# args: --issues-exit-code=0 | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 - 2020 Marcello de Sales | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright © 2019 Marcello de Sales <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package git | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/marcellodesales/cloner/config" | ||
"github.com/marcellodesales/cloner/util" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
/** | ||
* Clones the repo implementation, returning the exit code and any error message | ||
*/ | ||
func CloneGitRepo(cloneRequest *CloneGitRepoRequest, config *config.Configuration) (int, []error) { | ||
log.Debugf("config.git.cloneBaseDir=%s", config.Git.CloneBaseDir) | ||
err := GitService.ParseRepoString(cloneRequest) | ||
if err != nil { | ||
return 1, []error{fmt.Errorf("git URL invalid: %v", err)} | ||
} | ||
|
||
if cloneRequest.Force { | ||
log.Info("Forcing clone...") | ||
} | ||
|
||
deletedExistingDir, err := GitService.VerifyCloneDir(cloneRequest, config) | ||
if deletedExistingDir { | ||
log.Infof("Deleted dir '%s'", cloneRequest.CloneLocation) | ||
} | ||
if err != nil { | ||
return 2, []error{fmt.Errorf("can't clone repo: %v", err), | ||
fmt.Errorf("you can specify --force or -f to delete the existing dir and clone again. " + | ||
"Make sure there are no panding changes")} | ||
} | ||
|
||
err = GitService.MakeCloneDir(cloneRequest, config) | ||
if err != nil { | ||
return 3, []error{fmt.Errorf("can't create the base clone repo '%s': %v", cloneRequest.Type.GetUserDir(), err)} | ||
} | ||
|
||
log.Infof("Cloning into '%s'", cloneRequest.CloneLocation) | ||
err = GitService.GoCloneRepo(cloneRequest, config) | ||
if err != nil { | ||
return 4, []error{fmt.Errorf("can't clone the repo at '%s': %v", cloneRequest.Type.GetRepoDir(), err)} | ||
|
||
} else { | ||
log.Info("Done...") | ||
} | ||
|
||
// Show the files cloned | ||
filesListTree, err := GitService.GoPrintTree(cloneRequest) | ||
if err != nil { | ||
return 5, []error{fmt.Errorf("can't show the cloned repo tree '%s': %v", cloneRequest.Type.GetRepoDir(), err)} | ||
} | ||
|
||
if util.IsLogInDebug() { | ||
log.Infof("\n%s", filesListTree) | ||
} | ||
|
||
return 0, nil | ||
} |
Oops, something went wrong.