Skip to content

Commit

Permalink
Fix SVN login return code bug (#4)
Browse files Browse the repository at this point in the history
* Fix SVN login return code bug
* Updating docker compose files with new GitHub Container Registry image path
  • Loading branch information
marcleblanc2 authored Feb 16, 2024
1 parent 734fae3 commit 7363d1f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Sourcegraph
config/service-account-key.json
bridge-repo-converter/repos-to-serve
config/config.yaml
config/service-account-key.json
docker-template/
repo-stats-svn/tmp-repo-metadata/
repo-stats-svn/*.csv
repo-stats-svn/repos.txt
repo-stats-svn/tmp-repo-metadata/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Docker compose also allows for easier upgrades, troubleshooting, monitoring, log
2. Clone this repo to a customer's bridge VM, install Docker and Docker's Compose plugin
3. Copy the config.yaml and service-account-key.json files from the Cloud Ops dashboard, and paste them in the files under the config directory
4. Modify the config.yaml copied from the Cloud Ops dashboard
- ` serviceAccountKeyFile: /service-account-key.json` so that the Go binary inside the running Docker container finds this file in the path that's mapped via the docker-compose.yaml file
- `serviceAccountKeyFile: /service-account-key.json` so that the Go binary inside the running Docker container finds this file in the path that's mapped via the docker-compose.yaml file
- Only include the `- dialAddress` entries that this cloud agent can reach, remove the others, so the Cloud instance doesn't try connecting to this instance for code hosts it can't reach
- Correct open ports from default 443 to 80
- Careful when pasting the config.yaml into Windows, because it may add weird line endings or extra spaces, which breaks YAML, as a whitespace-dependent format
Expand Down
3 changes: 2 additions & 1 deletion bridge-repo-converter/build/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ services:
context: .
container_name: repo-conversion-bridge
volumes:
- ../config/repos-to-convert.yaml:/sourcegraph/repos-to-convert.yaml
- ../config/repos-to-convert.yaml:/sourcegraph/repos-to-convert.yaml:ro
- ../repos-to-serve/:/repos-to-serve
environment:
- BRIDGE_REPO_CONVERTER_INTERVAL_MINUTES=1
- LOG_LEVEL=debug
networks:
- sourcegraph

Expand Down
36 changes: 33 additions & 3 deletions bridge-repo-converter/build/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,25 @@
### Notes
# See this migration guide https://www.atlassian.com/git/tutorials/migrating-convert
# Especially the Clean the new Git repository, to convert branches and tags
# git config svn.authorsfile
# Java script repo
# https://marc-dev.sourcegraphcloud.com/bitbucket.org/atlassian/svn-migration-scripts/-/blob/src/main/scala/Authors.scala

# authors file
# java -jar /sourcegraph/svn-migration-scripts.jar authors https://svn.apache.org/repos/asf/eagle > authors.txt
# Kinda useful, surprisingly fast
# git config svn.authorsfile

# clean-git
# java -Dfile.encoding=utf-8 -jar /sourcegraph/svn-migration-scripts.jar clean-git
# Initial output looked good
# Required a working copy
# Didn't work
# Corrupted repo

# Find a python library for manipulating git repos

# An example of doing the conversion in Python, not sure why when git svn exists
# https://sourcegraph.com/github.com/gabrys/svn2github/-/blob/svn2github.py


## Import libraries
Expand Down Expand Up @@ -191,7 +209,9 @@ def clone_svn_repos(args_dict, repos_dict):
logging.info(f"Logging in to SVN repo {repo_key} with username {username}")
result = subprocess.run(["svn", "info", "--non-interactive", "--username", username, "--password", password, svn_repo_code_root])

if result == 0:
logging.debug(f"Result of svn info login command: {result}")

if result.returncode == 0:

logging.info(f"Logged in successfully to SVN repo {repo_key} with username {username}")

Expand Down Expand Up @@ -265,10 +285,20 @@ def clone_svn_repos(args_dict, repos_dict):

# Fork the process

subprocess.run(["git", "-C", repo_path, "svn", "fetch"], check=True)
result = subprocess.run(["git", "-C", repo_path, "svn", "fetch"], check=True, capture_output=True, text=True)
#fork_and_forget(["git", "-C", repo_path, "svn", "fetch"])
# Create the lockfile with the forked pid number

logging.debug(f"git svn fetch: {result}")

if result.returncode == 0:

logging.info(f"git svn fetch succeeded for {repo_key}")

else:

logging.warning(f"git svn fetch failed for {repo_key}")


def clone_tfs_repos(args_dict, repos_dict):

Expand Down
6 changes: 3 additions & 3 deletions bridge-repo-converter/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: '2.4'

services:

repo-conversion-bridge:
container_name: repo-conversion-bridge
image: repo-conversion-bridge
bridge-repo-converter:
container_name: bridge-repo-converter
image: ghcr.io/sourcegraph/bridge-repo-converter:latest
volumes:
- ./config/repos-to-convert.yaml:/sourcegraph/repos-to-convert.yaml:ro
- ../repos-to-serve/:/repos-to-serve
Expand Down

0 comments on commit 7363d1f

Please sign in to comment.