Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
124 lines (104 loc) · 3.57 KB

File metadata and controls

executable file
·
124 lines (104 loc) · 3.57 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env ruby
require 'optparse'
require_relative '../deployment.rb'
require 'cdo/git_utils'
require 'cdo/only_one'
CONTENT_PATHS = 'dashboard pegasus aws/dms'.freeze
# Revert any local changes to these files on levelbuilder
LEVELBUILDER_OMISSIONS = [
'dashboard/db/schema_cache.dump',
]
def ask_for_name
name = ''
until name != ''
print "Who are you? "
name = gets.chomp
end
puts "Hi #{name}!"
name
end
def disallow_case_change
`git add -A #{CONTENT_PATHS}`
ignore_levelbuilder_omissions
`git status --porcelain --untracked-files=all #{CONTENT_PATHS}`.split("\n").each do |line|
next unless (%r{^R ([^ ]+) -> ([^ ]+)}.match(line) || %r{^R ("[^"]+") -> ("[^"]+")}.match(line)) && $1.casecmp($2) == 0
STDERR.puts "\nAborting due to case-only rename:\n\n #{line}\n\n"
STDERR.puts "To fix this, run the following commands:\n\n"
STDERR.puts " git add #{$2}\n\n"
STDERR.puts " git mv #{$2} #{$2}.tmp\n\n"
STDERR.puts " git commit --only #{$1} #{$2}.tmp -m 'temporarily rename #{$1} -> #{$2}.tmp'\n\n"
STDERR.puts " git mv #{$2}.tmp #{$2}\n\n"
STDERR.puts " bin/content-push\n\n"
# unstage all changes so the above instructions can be followed
`git reset HEAD`
exit 1
end
end
def disallow_state_pdf
`git status --porcelain --untracked-files=all #{CONTENT_PATHS}`.split("\n").each do |line|
next unless %r{pegasus/sites.v3/code.org/public/advocacy/state-facts/..\.pdf$} =~ line
STDERR.puts "\nAborting because state pdf generation appears to be in progress:\n\n #{line}\n\n"
STDERR.puts "Please wait 10 minutes and then try again.\n\n"
`git reset HEAD`
exit 1
end
end
def ignore_levelbuilder_omissions
if GitUtils.current_branch == 'levelbuilder'
system("git reset -q HEAD -- '#{LEVELBUILDER_OMISSIONS.join("' '")}'")
system("git checkout -q HEAD -- '#{LEVELBUILDER_OMISSIONS.join("' '")}'")
end
end
def has_changes?
!`git status --porcelain --untracked-files=all #{CONTENT_PATHS}`.empty?
end
def check_changes
unless has_changes?
puts "There are no unstaged or untracked files to commit."
return false
end
disallow_case_change
disallow_state_pdf
system("git status --untracked-files=all #{CONTENT_PATHS}")
print "Should I commit and push all of these unstaged and untracked files in pegasus and dashboard? [Y/n] "
input = gets.chomp
if input == '' || input[0].downcase == 'y'
puts "Cool!"
true
else
puts "Ok, not doing anything."
false
end
end
def commit_changes(name)
exit 0 unless has_changes?
branchname = GitUtils.current_branch
exit 1 unless system("git add -A #{CONTENT_PATHS}")
ignore_levelbuilder_omissions
exit 1 unless system("git commit -m '#{branchname} content changes (-#{name})'")
exit 1 unless system("git pull")
exit 1 unless system("git push")
end
options = {}
OptionParser.new do |opts|
opts.on('-n', '--name NAME', 'Your name, or name of the process doing this commit') do |name|
options['name'] = name
end
opts.on('-s', '--subdirectory SUBDIRECTORY', 'Only push changes in this subdirectory') do |subdir|
options['subdirectory'] = subdir
end
opts.on('-f', '--force', 'Damn the torpedos, just do the commit and push, requires name') do
options['force'] = true
end
opts.on('-h', '--help', 'Print this') do
puts opts
exit
end
end.parse!
raise OptionParser::MissingArgument, 'Name is required if forcing push' if options['force'] && options['name'].nil?
Dir.chdir(deploy_dir) do
name = options['name'] || ask_for_name
if options['force'] || check_changes
commit_changes(name)
end
end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.