-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delete old assignments and add fetch script
- Loading branch information
1 parent
379d76b
commit de5e072
Showing
68 changed files
with
38 additions
and
7,242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import subprocess | ||
import shutil | ||
import os | ||
import argparse | ||
|
||
|
||
def find_last_commit_with_path(path): | ||
try: | ||
commit_hash = subprocess.check_output( | ||
["git", "log", "-n", "1", "--pretty=format:%H", "--", path], | ||
stderr=subprocess.DEVNULL | ||
).decode("utf-8").strip() | ||
return commit_hash | ||
except subprocess.CalledProcessError: | ||
return None | ||
|
||
def copy_from_commit(commit_hash, path): | ||
os.makedirs(path, exist_ok=True) | ||
subprocess.run(["git", "checkout", commit_hash, "--", path]) | ||
shutil.copytree(path, path, dirs_exist_ok=True) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Copies an old assignment into the worktree.") | ||
parser.add_argument("assignment", help="An assignment, e.g. 'assign0', 'assign1', etc.") | ||
args = parser.parse_args() | ||
|
||
path = args.assignment | ||
commit_hash = find_last_commit_with_path(path) | ||
|
||
if commit_hash: | ||
print(f"Last commit for {path}: {commit_hash}") | ||
copy_from_commit(commit_hash, path) | ||
print(f"Copied {path} from commit {commit_hash}.") | ||
else: | ||
print(f"No commits found for the specified assignment: {path}.") | ||
|
||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.