Skip to content

Commit

Permalink
fix: add git-continue
Browse files Browse the repository at this point in the history
address review comments, fix the script, remove unnecessary testpath
import.
  • Loading branch information
oikarinen committed Nov 22, 2024
1 parent 27ac89b commit d359df9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions bin/git-abort
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/usr/bin/env bash

set -xuo pipefail
set -euo pipefail

function discover_op() {
local gitdir
# git rev-parse emits an error if not in a git repo so only need to bail out
gitdir="$(git rev-parse --git-dir)" || exit
local op
for op in cherry_pick merge rebase revert ; do
test -f "${gitdir}/${op^^}_HEAD" && echo "${op/_/-}";
if [ -f "${gitdir}/${op^^}_HEAD" ]; then
echo "${op/_/-}"
fi
done
}

Expand Down
20 changes: 12 additions & 8 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os, subprocess, shutil, tempfile
import os
import subprocess
import shutil
import tempfile
from git import Repo, GitCommandError
from testpath import MockCommand, modified_env

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
GIT_EXTRAS_BIN = os.path.abspath(os.path.join(CURRENT_DIR, "..", "bin"))
Expand All @@ -10,15 +12,16 @@
GITLAB_ORIGIN = "https://gitlab.com/tj/git-extras.git"
BITBUCKET_ORIGIN = "https://bitbucket.org/tj/git-extras.git"


class TempRepository:
def __init__(self, repo_work_dir = None):
def __init__(self, repo_work_dir=None):
self._system_tmpdir = tempfile.gettempdir()
if repo_work_dir == None:
repo_work_dir = tempfile.mkdtemp()
else:
repo_work_dir = os.path.join(self._system_tmpdir, repo_work_dir)
self._cwd = repo_work_dir
self._tempdirname = self._cwd[len(self._system_tmpdir) + 1:]
self._tempdirname = self._cwd[len(self._system_tmpdir) + 1 :]
self._git_repo = Repo.init(repo_work_dir, b="default")
self._files = []
self.change_origin_to_github()
Expand Down Expand Up @@ -50,7 +53,7 @@ def create_tmp_dir(self):
tmp_dir = tempfile.mkdtemp()
return tmp_dir

def create_tmp_file(self, temp_dir = None):
def create_tmp_file(self, temp_dir=None):
if temp_dir == None:
temp_dir = self._cwd

Expand Down Expand Up @@ -86,8 +89,9 @@ def invoke_installed_extras_command(self, name, *params):
origin_extras_command = os.path.join(GIT_EXTRAS_BIN, command_name)
temp_extras_command = os.path.join(self._cwd, command_name)
helpers = [
os.path.join(GIT_EXTRAS_HELPER, "git-extra-utility"),
os.path.join(GIT_EXTRAS_HELPER, "is-git-repo")]
os.path.join(GIT_EXTRAS_HELPER, "git-extra-utility"),
os.path.join(GIT_EXTRAS_HELPER, "is-git-repo"),
]

if not os.path.exists(temp_extras_command):
whole = []
Expand All @@ -106,7 +110,7 @@ def invoke_installed_extras_command(self, name, *params):
os.chmod(temp_extras_command, 0o775)

script = [temp_extras_command, *params]
print(f"Run the script \"{script}\"")
print(f'Run the script "{script}"')
return subprocess.run(script, capture_output=True)

def change_origin(self, origin_url):
Expand Down

0 comments on commit d359df9

Please sign in to comment.