-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-import
- Loading branch information
Showing
6 changed files
with
97 additions
and
71 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,28 @@ | ||
#!/usr/bin/env sh | ||
|
||
# usage: ./gitmerge_ort_imports.sh <clone_dir> <branch-1> <branch-2> | ||
|
||
clone_dir=$1 | ||
branch1=$2 | ||
branch2=$3 | ||
|
||
export JAVA_HOME="$JAVA17_HOME" | ||
|
||
cd "$clone_dir" || exit 1 | ||
|
||
git checkout "$branch1" --force | ||
|
||
attributes_file=".git/info/attributes" | ||
echo "*.java merge=merge-java" >> "$attributes_file" | ||
git config --local merge.merge-java.name "Merge Java files" | ||
git config --local merge.merge-java.driver 'java-merge-driver.sh "%A" "%O" "%B"' | ||
|
||
git merge --no-edit "$branch2" | ||
retVal=$? | ||
|
||
# report conflicts | ||
if [ "$retVal" -ne 0 ]; then | ||
echo "Conflict" | ||
fi | ||
|
||
exit "$retVal" |
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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
""" Delete the keys containing 'imports' in the JSON files in the given directory. """ | ||
import os | ||
import json | ||
|
||
|
||
def count_import_keys(directory): | ||
"""Count the number of keys containing 'imports' in the JSON files in the given directory.""" | ||
count = 0 | ||
for root, _, files in os.walk(directory): | ||
json_files = [f for f in files if f.endswith(".json")] | ||
for json_file in json_files: | ||
file_path = os.path.join(root, json_file) | ||
with open(file_path, "r", encoding="utf-8") as file: | ||
data = json.load(file) | ||
|
||
# Count keys containing 'adjacent' | ||
keys_to_delete = [key for key in data if "adjacent" in key] | ||
count += len(keys_to_delete) | ||
return count | ||
|
||
|
||
def delete_import_keys(directory): | ||
"""Delete the keys containing 'imports' in the JSON files in the given directory.""" | ||
total_deleted = 0 | ||
for root, _, files in os.walk(directory): | ||
json_files = [f for f in files if f.endswith(".json")] | ||
for json_file in json_files: | ||
file_path = os.path.join(root, json_file) | ||
with open(file_path, "r", encoding="utf-8") as file: | ||
data = json.load(file) | ||
|
||
# Record keys to delete | ||
keys_to_delete = [key for key in data.keys() if "adjacent" in key] | ||
if keys_to_delete: | ||
for key in keys_to_delete: | ||
del data[key] | ||
total_deleted += 1 | ||
|
||
# Save the modified data back to file | ||
with open(file_path, "w", encoding="utf-8") as file: | ||
json.dump(data, file, indent=4) | ||
|
||
return total_deleted | ||
|
||
|
||
def main(): | ||
"""Main function.""" | ||
directory = "cache" | ||
potential_deletions = count_import_keys(directory) | ||
print(f"Potential deletions: {potential_deletions}") | ||
confirm = input("Do you want to proceed with deleting these keys? (yes/no): ") | ||
if confirm.lower() == "yes": | ||
total_deleted = delete_import_keys(directory) | ||
print(f"Total keys deleted: {total_deleted}") | ||
else: | ||
print("Operation cancelled.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
git-hires-merge is from https://github.com/paulaltin/git-hires-merge . | ||
|
||
resolve-adjacent-conflicts, resolve-conflicts.py, and resolve-import-conflicts | ||
are from https://github.com/plume-lib/manage-git-branches . |
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 |
---|---|---|
@@ -1,20 +1,17 @@ | ||
#!/usr/bin/env sh | ||
|
||
# usage: ./gitmerge_ort_adjacent.sh <clone_dir> <branch-1> <branch-2> | ||
# usage: ./gitmerge_ort_imports.sh <clone_dir> <branch-1> <branch-2> | ||
|
||
MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" | ||
clone_dir=$1 | ||
branch1=$2 | ||
branch2=$3 | ||
strategy="-s ort" | ||
if "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy"; then | ||
exit 0 | ||
fi | ||
|
||
export JAVA_HOME="$JAVA17_HOME" | ||
|
||
cd "$clone_dir" || exit 1 | ||
if ! "$MERGE_SCRIPTS_DIR"/resolve-adjacent-conflicts; then | ||
echo "gitmerge_ort_adjacent.sh: Conflict" | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
exit "$retVal" |
This file was deleted.
Oops, something went wrong.