Christine Ye commited on
Commit
e7898c2
Β·
1 Parent(s): 3c74b88

Merge with main - auto-resolved

Browse files
Files changed (1) hide show
  1. resolve.sh +35 -40
resolve.sh CHANGED
@@ -39,51 +39,46 @@ resolve_gitattributes() {
39
 
40
  git checkout pr/$pr_num 2>/dev/null
41
 
42
- # Check if there are any conflicts
43
- if ! git status --porcelain | grep -q "^UU"; then
44
- echo " ℹ️ No conflicts found in PR #$pr_num"
45
- return 0
46
- fi
47
-
48
- # Check if .gitattributes has conflicts
49
- if ! git status --porcelain | grep -q "^UU .gitattributes"; then
50
- echo " ℹ️ No .gitattributes conflicts in PR #$pr_num"
51
- return 0
52
- fi
53
-
54
- echo " πŸ”§ Resolving .gitattributes conflict..."
55
 
56
- # Auto-resolve .gitattributes by taking both sides and removing duplicates
57
- # This assumes the conflict is just duplicate LFS entries
58
- if [ -f .gitattributes ]; then
59
- # Remove conflict markers and duplicate lines
60
- grep -v "^<<<<<<<" .gitattributes | \
61
- grep -v "^=======" | \
62
- grep -v "^>>>>>>>" | \
63
- sort -u > .gitattributes.tmp
64
-
65
- mv .gitattributes.tmp .gitattributes
66
-
67
- # Stage the resolved file
68
- git add .gitattributes
69
 
70
- # Commit the resolution
71
- if git commit -m "Resolve .gitattributes merge conflict - auto-resolved" 2>/dev/null; then
72
- echo " βœ… Conflict resolved and committed"
 
 
 
 
 
73
 
74
- # Push back to HF
75
- if git push origin pr/$pr_num:refs/pr/$pr_num 2>/dev/null; then
76
- echo " βœ… Successfully pushed to HuggingFace PR #$pr_num"
77
- else
78
- echo " ❌ Failed to push to HuggingFace PR #$pr_num"
79
- return 1
80
- fi
81
- else
82
- echo " ❌ Failed to commit resolution for PR #$pr_num"
83
- return 1
84
  fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  else
86
- echo " ❌ .gitattributes file not found in PR #$pr_num"
87
  return 1
88
  fi
89
 
 
39
 
40
  git checkout pr/$pr_num 2>/dev/null
41
 
42
+ # Try to merge with main to trigger any conflicts
43
+ echo " πŸ”„ Attempting merge with main..."
44
+ merge_output=$(git merge main 2>&1)
45
+ merge_status=$?
 
 
 
 
 
 
 
 
 
46
 
47
+ if [ $merge_status -eq 0 ]; then
48
+ echo " ℹ️ No conflicts found in PR #$pr_num (merge successful)"
49
+ else
50
+ echo " πŸ”§ Merge conflicts detected, resolving..."
 
 
 
 
 
 
 
 
 
51
 
52
+ # Check if .gitattributes has conflicts and resolve them
53
+ if [ -f .gitattributes ] && grep -q "^<<<<<<<" .gitattributes; then
54
+ echo " πŸ”§ Resolving .gitattributes conflict..."
55
+ # Remove conflict markers and duplicate lines
56
+ grep -v "^<<<<<<<" .gitattributes | \
57
+ grep -v "^=======" | \
58
+ grep -v "^>>>>>>>" | \
59
+ sort -u > .gitattributes.tmp
60
 
61
+ mv .gitattributes.tmp .gitattributes
 
 
 
 
 
 
 
 
 
62
  fi
63
+ fi
64
+
65
+ # Always stage all files and commit/push regardless of merge status
66
+ echo " πŸ“¦ Staging all files..."
67
+ git add .
68
+
69
+ # Commit (this will work whether there were conflicts or not)
70
+ if git commit -m "Merge with main - auto-resolved" 2>/dev/null; then
71
+ echo " βœ… Changes committed"
72
+ else
73
+ echo " ℹ️ No changes to commit (already up to date)"
74
+ fi
75
+
76
+ # Always try to push
77
+ echo " πŸš€ Pushing to HuggingFace..."
78
+ if git push origin pr/$pr_num:refs/pr/$pr_num 2>/dev/null; then
79
+ echo " βœ… Successfully pushed to HuggingFace PR #$pr_num"
80
  else
81
+ echo " ❌ Failed to push to HuggingFace PR #$pr_num"
82
  return 1
83
  fi
84