git-maintain 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -0
- data/README.md +1 -1
- data/bin/git-maintain +8 -5
- data/lib/addons/RDMACore.rb +16 -7
- data/lib/addons/git-maintain.rb +66 -0
- data/lib/azure.rb +98 -0
- data/lib/branch.rb +62 -34
- data/lib/common.rb +13 -5
- data/lib/repo.rb +6 -10
- data/lib/travis.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868f7d13ca258e469a2a32f892646f22486c006b2dd6cdd927a8df4ee349aaaf
|
4
|
+
data.tar.gz: ee9fabe23d3918015bd195d67ca36d528dba9d993574749134e338143d06429f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306f260c676c76fc85d2bf87b797e3e8831cdcdd5fb0d847f3d7515e6b68ca35d271dd2348d6b1f850300c22a806be344b8eeeac382e9ed02ab19d3dabe18aab
|
7
|
+
data.tar.gz: c7a5aae40d1ab800006f6bc8aa9674eaced5a9acc5ec92a71e338d85a75e9e19768dce0be894b3a846c7976a5b2df189292c2973d31c86aadf0e9a9fdbd66a4e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
------------------
|
2
|
+
0.9.0 (2022-10-18)
|
3
|
+
------------------
|
4
|
+
|
5
|
+
* Do not push branches already in stable to valid repository
|
6
|
+
* Add --yes support
|
7
|
+
* Add --base option for 'steal' command
|
8
|
+
* Add --no-edit option for 'release' command
|
9
|
+
* Enhance subcommands help/usage
|
10
|
+
* RDMACore updates
|
11
|
+
* Allow 'steal' to restart from a given SHA1
|
12
|
+
* Fix Github and Rybygem deployment
|
13
|
+
|
1
14
|
------------------
|
2
15
|
0.8.0 (2020-03-04)
|
3
16
|
------------------
|
data/README.md
CHANGED
@@ -282,7 +282,7 @@ This is a summary of all the settings that can be set in the git config:
|
|
282
282
|
Unless otherwise stated, everything in this repo is covered by the following
|
283
283
|
copyright notice:
|
284
284
|
|
285
|
-
Copyright (c)
|
285
|
+
Copyright (c) 2022 SUSE
|
286
286
|
|
287
287
|
This program is free software: you can redistribute it and/or modify it
|
288
288
|
under the terms of the GNU General Public License version 3, as
|
data/bin/git-maintain
CHANGED
@@ -11,17 +11,17 @@ $LOAD_PATH.pop()
|
|
11
11
|
|
12
12
|
opts = {
|
13
13
|
:br_suff => "master",
|
14
|
-
:
|
14
|
+
:yn_default => nil,
|
15
15
|
}
|
16
|
-
|
16
|
+
ACTION_HELPS = GitMaintain::getActionAttr("ACTION_HELP")
|
17
17
|
actionParser = OptionParser.new(nil, 60)
|
18
18
|
actionParser.banner = "Usage: #{__FILE__} <action> [action options]"
|
19
19
|
actionParser.separator ""
|
20
20
|
actionParser.separator "Options:"
|
21
21
|
actionParser.on("-h", "--help", "Display usage.") { |val| puts actionParser.to_s; exit 0 }
|
22
22
|
actionParser.separator "Possible actions:"
|
23
|
-
|
24
|
-
actionParser.separator "\t " + x
|
23
|
+
ACTION_HELPS.each(){|k, x|
|
24
|
+
actionParser.separator "\t * " + k.to_s() + ": " + x
|
25
25
|
}
|
26
26
|
rest = actionParser.order!(ARGV);
|
27
27
|
if rest.length <= 0 then
|
@@ -38,13 +38,16 @@ ARGV.shift()
|
|
38
38
|
|
39
39
|
optsParser = OptionParser.new(nil, 60)
|
40
40
|
optsParser.banner = "Usage: #{__FILE__} #{action_s} "
|
41
|
+
optsParser.separator "# " + ACTION_HELPS[action].to_s()
|
41
42
|
optsParser.separator ""
|
42
43
|
optsParser.separator "Options:"
|
43
44
|
optsParser.on("-h", "--help", "Display usage.") { |val| puts optsParser.to_s; exit 0 }
|
44
45
|
optsParser.on("-b", "--branch-suffix [SUFFIX]", "Branch suffix. Default is 'master'.") {
|
45
46
|
|val| opts[:br_suff] = val}
|
46
47
|
optsParser.on("-n", "--no", "Assume no to all questions.") {
|
47
|
-
|val| opts[:
|
48
|
+
|val| opts[:yn_default] = :no}
|
49
|
+
optsParser.on("-y", "--yes", "Assume yes to all questions.") {
|
50
|
+
|val| opts[:yn_default] = :yes}
|
48
51
|
optsParser.on("--verbose", "Displays more informations.") {
|
49
52
|
|val| GitMaintain::setVerbose(true)}
|
50
53
|
GitMaintain::setOpts(action, optsParser, opts)
|
data/lib/addons/RDMACore.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module GitMaintain
|
2
2
|
class RDMACoreBranch < Branch
|
3
3
|
REPO_NAME = "rdma-core"
|
4
|
-
AZURE_MIN_VERSION =
|
4
|
+
AZURE_MIN_VERSION = 18
|
5
5
|
|
6
6
|
def self.set_opts(action, optsParser, opts)
|
7
7
|
opts[:rel_type] = nil
|
@@ -16,8 +16,14 @@ module GitMaintain
|
|
16
16
|
end
|
17
17
|
def self.check_opts(opts)
|
18
18
|
if opts[:action] == :release then
|
19
|
-
|
19
|
+
case opts[:rel_type]
|
20
|
+
when nil
|
20
21
|
raise "No release type specified use --stable or --major"
|
22
|
+
when :major
|
23
|
+
if opts[:manual_branch] == nil then
|
24
|
+
GitMaintain::log(:INFO, "Major release selected. Auto-forcing branch to master")
|
25
|
+
opts[:manual_branch] = "master"
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -65,9 +71,12 @@ module GitMaintain
|
|
65
71
|
tag_file.puts `git log HEAD ^#{git_prev_ver} --no-merges --format=' * %s'`
|
66
72
|
tag_file.close()
|
67
73
|
|
74
|
+
edit_flag = ""
|
75
|
+
edit_flag = "--edit" if opts[:no_edit] == false
|
76
|
+
|
68
77
|
if opts[:rel_type] == :major
|
69
78
|
# For major, tag the current version first
|
70
|
-
@repo.runGitInteractive("tag -a -s v#{rel_ver}
|
79
|
+
@repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}")
|
71
80
|
if $? != 0 then
|
72
81
|
raise("Failed to tag branch #{local_branch}")
|
73
82
|
end
|
@@ -95,13 +104,13 @@ mv debian/changelog.new debian/changelog")
|
|
95
104
|
|
96
105
|
# Add and commit
|
97
106
|
@repo.runGit("add */*.spec CMakeLists.txt debian/changelog")
|
98
|
-
@repo.runGitInteractive("commit -m '#{commit_msg} #{new_ver}' --verbose
|
107
|
+
@repo.runGitInteractive("commit -m '#{commit_msg} #{new_ver}' --verbose #{edit_flag} --signoff")
|
99
108
|
if $? != 0 then
|
100
109
|
raise("Failed to commit on branch #{local_branch}")
|
101
110
|
end
|
102
111
|
|
103
112
|
if opts[:rel_type] == :stable
|
104
|
-
@repo.runGitInteractive("tag -a -s v#{rel_ver}
|
113
|
+
@repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}")
|
105
114
|
if $? != 0 then
|
106
115
|
raise("Failed to tag branch #{local_branch}")
|
107
116
|
end
|
@@ -110,7 +119,7 @@ mv debian/changelog.new debian/changelog")
|
|
110
119
|
end
|
111
120
|
end
|
112
121
|
class RDMACoreRepo < Repo
|
113
|
-
AZURE_MIN_VERSION =
|
122
|
+
AZURE_MIN_VERSION = 18
|
114
123
|
def submitReleases(opts, new_tags)
|
115
124
|
new_tags.each(){|tag|
|
116
125
|
next if tag !~ /v([0-9]*)\.[0-9]*/
|
@@ -122,7 +131,7 @@ mv debian/changelog.new debian/changelog")
|
|
122
131
|
end
|
123
132
|
|
124
133
|
class RDMACoreCI < CI
|
125
|
-
AZURE_MIN_VERSION =
|
134
|
+
AZURE_MIN_VERSION = 18
|
126
135
|
def initialize(repo)
|
127
136
|
super(repo)
|
128
137
|
@travis = GitMaintain::TravisCI.new(repo)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module GitMaintain
|
2
|
+
class GitMaintainBranch < Branch
|
3
|
+
REPO_NAME = "git-maintain"
|
4
|
+
|
5
|
+
def release(opts)
|
6
|
+
prev_ver=@repo.runGit("show HEAD:CHANGELOG | grep -A 1 -- '---------' | head -n 2 | tail -n 1 | awk '{ print $1}'").chomp()
|
7
|
+
ver_nums = prev_ver.split(".")
|
8
|
+
|
9
|
+
if opts[:manual_branch] == nil then
|
10
|
+
new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".")
|
11
|
+
git_prev_ver = "v" + (ver_nums[-1] == "0" ? ver_nums[0 .. -2].join(".") : prev_ver)
|
12
|
+
else
|
13
|
+
new_ver = (ver_nums[0 .. -3] + [ver_nums[-2].to_i() + 1 ] + [ "0" ]).join(".")
|
14
|
+
git_prev_ver = "v" + prev_ver
|
15
|
+
end
|
16
|
+
|
17
|
+
changes=@repo.runGit("show HEAD:CHANGELOG | awk ' BEGIN {count=0} {if ($1 == \"------------------\") count++; if (count == 0) print $0}'")
|
18
|
+
|
19
|
+
puts "Preparing release #{prev_ver} => #{new_ver}"
|
20
|
+
rep = GitMaintain::checkLog(opts, @local_branch, git_prev_ver, "release")
|
21
|
+
if rep != "y" then
|
22
|
+
puts "Skipping release"
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
# Prepare tag message
|
27
|
+
tag_path=`mktemp`.chomp()
|
28
|
+
puts tag_path
|
29
|
+
tag_file = File.open(tag_path, "w+")
|
30
|
+
tag_file.puts "git-maintain-#{new_ver}"
|
31
|
+
tag_file.puts ""
|
32
|
+
tag_file.puts changes
|
33
|
+
tag_file.close()
|
34
|
+
|
35
|
+
@repo.run("cat <<EOF > CHANGELOG.new
|
36
|
+
------------------
|
37
|
+
#{new_ver} #{`date '+ (%Y-%m-%d)'`.chomp()}
|
38
|
+
------------------
|
39
|
+
|
40
|
+
$(cat CHANGELOG)
|
41
|
+
EOF
|
42
|
+
mv CHANGELOG.new CHANGELOG")
|
43
|
+
|
44
|
+
# Add and commit
|
45
|
+
@repo.runGit("add CHANGELOG")
|
46
|
+
@repo.runGitInteractive("commit -F #{tag_path} --verbose --edit --signoff")
|
47
|
+
if $? != 0 then
|
48
|
+
raise("Failed to commit on branch #{local_branch}")
|
49
|
+
end
|
50
|
+
@repo.runGitInteractive("tag -a -s v#{new_ver} --edit -F #{tag_path}")
|
51
|
+
if $? != 0 then
|
52
|
+
raise("Failed to tag branch #{local_branch}")
|
53
|
+
end
|
54
|
+
`rm -f #{tag_path}`
|
55
|
+
end
|
56
|
+
end
|
57
|
+
class GitMaintainRepo < Repo
|
58
|
+
def initialize(path)
|
59
|
+
super(path)
|
60
|
+
@NOTIFY_RELEASE = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
GitMaintain::registerCustom(GitMaintainBranch::REPO_NAME,
|
64
|
+
{ GitMaintain::Branch => GitMaintainBranch,
|
65
|
+
GitMaintain::Repo => GitMaintainRepo})
|
66
|
+
end
|
data/lib/azure.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
module GitMaintain
|
2
|
+
class AzureCI < CI
|
3
|
+
AZURE_URL='https://dev.azure.com/'
|
4
|
+
|
5
|
+
def initialize(repo, stable='', valid='')
|
6
|
+
super(repo)
|
7
|
+
@url = AZURE_URL
|
8
|
+
@stable_org=stable
|
9
|
+
@valid_org=valid
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def getState(sha1, resp)
|
14
|
+
br = findBranch(sha1, resp)
|
15
|
+
return "not found" if br == nil
|
16
|
+
return "running" if br["result"] == nil
|
17
|
+
return br["result"].to_s()
|
18
|
+
end
|
19
|
+
def getLog(sha1, resp)
|
20
|
+
str=""
|
21
|
+
# br = findBranch(sha1, resp)
|
22
|
+
# raise("Travis build not found") if br == nil
|
23
|
+
# job_id = br["id"].to_s()
|
24
|
+
# logs= getJson(@url, "azure_log_list" + job_id,
|
25
|
+
# @repo.name + "/_apis/build/builds/#{job_id}/logs?api-version=5.1")
|
26
|
+
# 1.upto(logs["count"]) { |x|
|
27
|
+
# log(:DEBUG_CI, "Downloading log file #{x}/#{logs["count"]}")
|
28
|
+
# nzstr = getJson(@url, "azure_log_" + job_id + '_' + x.to_s(),
|
29
|
+
# @repo.name + "/_apis/build/builds/#{job_id}/logs/#{x}?api-version=5.1", false)
|
30
|
+
# # This is zipped. We need to extract it
|
31
|
+
# }
|
32
|
+
return str
|
33
|
+
end
|
34
|
+
def getTS(sha1, resp)
|
35
|
+
br = findBranch(sha1, resp)
|
36
|
+
raise("Travis build not found") if br == nil
|
37
|
+
return br["started_at"]
|
38
|
+
end
|
39
|
+
def checkState(sha1, resp)
|
40
|
+
st = getState(sha1, resp)
|
41
|
+
return st == "passed" || st == "succeeded"
|
42
|
+
end
|
43
|
+
|
44
|
+
def getBrValidJson()
|
45
|
+
raise("Validation organisation not provided") if @valid_org == ''
|
46
|
+
return getJson(@url + @valid_org + '/',
|
47
|
+
:azure_br_valid, @repo.name + '/_apis/build/builds?api-version=5.1')
|
48
|
+
end
|
49
|
+
def getBrStableJson()
|
50
|
+
raise("Stable organisation not provided") if @stable_org == ''
|
51
|
+
return getJson(@url + @stable_org + '/',
|
52
|
+
:azure_br_stable, @repo.name + '/_apis/build/builds?api-version=5.1')
|
53
|
+
end
|
54
|
+
def findBranch(sha1, resp)
|
55
|
+
log(:DEBUG_CI, "Looking for build for #{sha1}")
|
56
|
+
resp["value"].each(){|br|
|
57
|
+
commit= br["sourceVersion"]
|
58
|
+
raise("Incomplete JSON received from Travis") if commit == nil
|
59
|
+
log(:DEBUG_CI, "Found entry for sha #{commit}")
|
60
|
+
next if commit != sha1
|
61
|
+
return br
|
62
|
+
}
|
63
|
+
return nil
|
64
|
+
end
|
65
|
+
|
66
|
+
public
|
67
|
+
def getValidState(br, sha1)
|
68
|
+
return getState(sha1, getBrValidJson())
|
69
|
+
end
|
70
|
+
def checkValidState(br, sha1)
|
71
|
+
return checkState(sha1, getBrValidJson())
|
72
|
+
end
|
73
|
+
def getValidLog(br, sha1)
|
74
|
+
return getLog(sha1, getBrValidJson())
|
75
|
+
end
|
76
|
+
def getValidTS(br, sha1)
|
77
|
+
return getTS(sha1, getBrValidJson())
|
78
|
+
end
|
79
|
+
|
80
|
+
def getStableState(br, sha1)
|
81
|
+
return getState(sha1, getBrStableJson())
|
82
|
+
end
|
83
|
+
def checkStableState(br, sha1)
|
84
|
+
return checkState(sha1, getBrStableJson())
|
85
|
+
end
|
86
|
+
def getStableLog(br, sha1)
|
87
|
+
return getLog(sha1, getBrStableJson())
|
88
|
+
end
|
89
|
+
def getStableTS(br, sha1)
|
90
|
+
return getTS(sha1, getBrStableJson())
|
91
|
+
end
|
92
|
+
def isErrored(br, status)
|
93
|
+
# https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/list?
|
94
|
+
# view=azure-devops-rest-5.1#buildresult
|
95
|
+
return status == "failed"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/branch.rb
CHANGED
@@ -24,21 +24,21 @@ module GitMaintain
|
|
24
24
|
ALL_BRANCHES_ACTIONS = [
|
25
25
|
:create
|
26
26
|
]
|
27
|
-
ACTION_HELP =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
27
|
+
ACTION_HELP = {
|
28
|
+
:cp => "Backport commits and eventually push them to github",
|
29
|
+
:create => "Create missing local branches from all the stable branches",
|
30
|
+
:delete => "Delete all local branches using the suffix",
|
31
|
+
:steal => "Steal commit from upstream that fixes commit in the branch or were tagged as stable",
|
32
|
+
:list => "List commit present in the branch but not in the stable branch",
|
33
|
+
:list_stable => "List commit present in the stable branch but not in the latest associated relase",
|
34
|
+
:merge => "Merge branch with suffix specified in -m <suff> into the main branch",
|
35
|
+
:push => "Push branches to github for validation",
|
36
|
+
:monitor => "Check the CI state of all branches",
|
37
|
+
:push_stable => "Push to stable repo",
|
38
|
+
:monitor_stable => "Check the CI state of all stable branches",
|
39
|
+
:release => "Create new release on all concerned branches",
|
40
|
+
:reset => "Reset branch against upstream",
|
41
|
+
}
|
42
42
|
|
43
43
|
def self.load(repo, version, ci, branch_suff)
|
44
44
|
repo_name = File.basename(repo.path)
|
@@ -52,11 +52,12 @@ module GitMaintain
|
|
52
52
|
opts[:do_merge] = false
|
53
53
|
opts[:push_force] = false
|
54
54
|
opts[:no_ci] = false
|
55
|
-
opts[:
|
55
|
+
opts[:steal_base] = nil
|
56
56
|
opts[:check_only] = false
|
57
57
|
opts[:fetch] = nil
|
58
58
|
opts[:watch] = false
|
59
59
|
opts[:delete_remote] = false
|
60
|
+
opts[:no_edit] = false
|
60
61
|
|
61
62
|
optsParser.on("-v", "--base-version [MIN_VER]", Integer, "Older release to consider.") {
|
62
63
|
|val| opts[:base_ver] = val}
|
@@ -101,11 +102,17 @@ module GitMaintain
|
|
101
102
|
|val| opts[:no_ci] = true}
|
102
103
|
optsParser.on("-c", "--check", "Check if there is something to be pushed.") {
|
103
104
|
|val| opts[:check_only] = true}
|
105
|
+
when :release
|
106
|
+
optsParser.on("--no-edit", "Do not edit release commit nor tag.") {
|
107
|
+
opts[:no_edit] = true }
|
104
108
|
when :steal
|
105
|
-
optsParser.banner += "[-a]"
|
109
|
+
optsParser.banner += "[-a][-b <HEAD>]"
|
106
110
|
optsParser.on("-a", "--all", "Check all commits from master. "+
|
107
111
|
"By default only new commits (since last successful run) are considered.") {
|
108
|
-
|val| opts[:
|
112
|
+
|val| opts[:steal_base] = :all}
|
113
|
+
optsParser.on("-b", "--base <HEAD>", "Check all commits from this commit. "+
|
114
|
+
"By default only new commits (since last successful run) are considered.") {
|
115
|
+
|val| opts[:steal_base] = val}
|
109
116
|
end
|
110
117
|
end
|
111
118
|
|
@@ -266,13 +273,23 @@ module GitMaintain
|
|
266
273
|
|
267
274
|
# If we are not force checking everything,
|
268
275
|
# try to start from the last tag we steal upto
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
+
case opts[:steal_base]
|
277
|
+
when nil
|
278
|
+
sha = @repo.runGit("rev-parse 'git-maintain/steal/last/#{@stable_base}' 2>&1")
|
279
|
+
if $? == 0 then
|
280
|
+
base_ref=sha
|
281
|
+
log(:VERBOSE, "Starting from last successfull run:")
|
282
|
+
log(:VERBOSE, @repo.getCommitHeadline(base_ref))
|
283
|
+
end
|
284
|
+
when :all
|
285
|
+
base_ref=@stable_base
|
286
|
+
else
|
287
|
+
sha = @repo.runGit("rev-parse #{opts[:steal_base]} 2>&1")
|
288
|
+
if $? == 0 then
|
289
|
+
base_ref=sha
|
290
|
+
log(:VERBOSE, "Starting from base:")
|
291
|
+
log(:VERBOSE, @repo.getCommitHeadline(base_ref))
|
292
|
+
end
|
276
293
|
end
|
277
294
|
|
278
295
|
master_sha=@repo.runGit("rev-parse origin/master")
|
@@ -333,8 +350,9 @@ module GitMaintain
|
|
333
350
|
|
334
351
|
# Push the branch to the validation repo
|
335
352
|
def push(opts)
|
336
|
-
if same_sha?(@local_branch, @repo.valid_repo + "/" + @local_branch)
|
337
|
-
|
353
|
+
if same_sha?(@local_branch, @repo.valid_repo + "/" + @local_branch) ||
|
354
|
+
same_sha?(@local_branch, @remote_ref) then
|
355
|
+
log(:INFO, "Nothing to push on #{@local_branch}")
|
338
356
|
return
|
339
357
|
end
|
340
358
|
return "#{@local_branch}:#{@local_branch}"
|
@@ -380,14 +398,14 @@ module GitMaintain
|
|
380
398
|
|
381
399
|
# Push branch to the stable repo
|
382
400
|
def push_stable(opts)
|
383
|
-
if (
|
384
|
-
|
385
|
-
log(:WARNING, "Build is not passed on CI. Skipping push to stable")
|
401
|
+
if same_sha?(@local_branch, @remote_ref) then
|
402
|
+
log(:INFO, "Stable is already up-to-date")
|
386
403
|
return
|
387
404
|
end
|
388
405
|
|
389
|
-
if
|
390
|
-
|
406
|
+
if (opts[:no_ci] != true && @NO_CI != true) &&
|
407
|
+
@ci.checkValidState(self, @head) != true then
|
408
|
+
log(:WARNING, "Build is not passed on CI. Skipping push to stable")
|
391
409
|
return
|
392
410
|
end
|
393
411
|
|
@@ -452,6 +470,11 @@ module GitMaintain
|
|
452
470
|
|
453
471
|
def delete(opts)
|
454
472
|
if opts[:delete_remote] == true then
|
473
|
+
@repo.runGit("rev-parse --verify --quiet #{@repo.valid_repo}/#{@local_branch}")
|
474
|
+
if $? != 0 then
|
475
|
+
log(:DEBUG, "Skipping non existing remote branch #{@local_branch}.")
|
476
|
+
return
|
477
|
+
end
|
455
478
|
msg = "delete remote branch #{@repo.valid_repo}/#{@local_branch}"
|
456
479
|
else
|
457
480
|
msg = "delete branch #{@local_branch}"
|
@@ -470,7 +493,7 @@ module GitMaintain
|
|
470
493
|
|
471
494
|
return if branches.length == 0
|
472
495
|
puts "Deleting #{opts[:delete_remote] == true ? "remote" : "local"} branches: #{branches.join(" ")}"
|
473
|
-
rep = GitMaintain::confirm(opts, "continue")
|
496
|
+
rep = GitMaintain::confirm(opts, "continue", true)
|
474
497
|
if rep != "y" then
|
475
498
|
log(:INFO, "Cancelling")
|
476
499
|
return
|
@@ -607,13 +630,18 @@ module GitMaintain
|
|
607
630
|
puts @repo.getCommitHeadline(commit)
|
608
631
|
while rep != "y" do
|
609
632
|
puts "Do you want to steal this commit ? (y/n/b/?)"
|
610
|
-
|
633
|
+
case opts[:yn_default]
|
634
|
+
when :no
|
611
635
|
log(:INFO, "Auto-replying no due to --no option")
|
612
636
|
rep = 'n'
|
613
637
|
break
|
638
|
+
when :yes
|
639
|
+
log(:INFO, "Auto-replying yes due to --yes option")
|
640
|
+
rep = 'y'
|
614
641
|
else
|
615
642
|
rep = STDIN.gets.chomp()
|
616
643
|
end
|
644
|
+
|
617
645
|
case rep
|
618
646
|
when "n"
|
619
647
|
log(:INFO, "Skip this commit")
|
data/lib/common.rb
CHANGED
@@ -44,7 +44,7 @@ end
|
|
44
44
|
module GitMaintain
|
45
45
|
class Common
|
46
46
|
ACTION_LIST = [ :list_actions ]
|
47
|
-
ACTION_HELP =
|
47
|
+
ACTION_HELP = {}
|
48
48
|
def self.execAction(opts, action)
|
49
49
|
puts GitMaintain::getActionAttr("ACTION_LIST").join("\n")
|
50
50
|
end
|
@@ -94,7 +94,11 @@ module GitMaintain
|
|
94
94
|
module_function :checkDirectConstructor
|
95
95
|
|
96
96
|
def getActionAttr(attr)
|
97
|
-
|
97
|
+
if Common.const_get(attr).class == Hash
|
98
|
+
return ACTION_CLASS.inject({}){|h, x| h.merge(x.const_get(attr))}
|
99
|
+
else
|
100
|
+
return ACTION_CLASS.map(){|x| x.const_get(attr)}.flatten()
|
101
|
+
end
|
98
102
|
end
|
99
103
|
module_function :getActionAttr
|
100
104
|
|
@@ -138,13 +142,17 @@ module GitMaintain
|
|
138
142
|
end
|
139
143
|
module_function :execAction
|
140
144
|
|
141
|
-
def confirm(opts, msg)
|
145
|
+
def confirm(opts, msg, ignore_default=false)
|
142
146
|
rep = 't'
|
143
147
|
while rep != "y" && rep != "n" && rep != '' do
|
144
148
|
puts "Do you wish to #{msg} ? (y/N): "
|
145
|
-
|
149
|
+
case (ignore_default == true ? nil : opts[:yn_default])
|
150
|
+
when :no
|
146
151
|
puts "Auto-replying no due to --no option"
|
147
152
|
rep = 'n'
|
153
|
+
when :yes
|
154
|
+
puts "Auto-replying yes due to --yes option"
|
155
|
+
rep = 'y'
|
148
156
|
else
|
149
157
|
rep = STDIN.gets.chomp()
|
150
158
|
end
|
@@ -155,7 +163,7 @@ module GitMaintain
|
|
155
163
|
|
156
164
|
def checkLog(opts, br1, br2, action_msg)
|
157
165
|
puts "Diff between #{br1} and #{br2}"
|
158
|
-
puts `git
|
166
|
+
puts `git log --format=oneline #{br1} ^#{br2}`
|
159
167
|
return "n" if action_msg.to_s() == ""
|
160
168
|
rep = confirm(opts, "#{action_msg} this branch")
|
161
169
|
return rep
|
data/lib/repo.rb
CHANGED
@@ -13,10 +13,10 @@ module GitMaintain
|
|
13
13
|
# Internal commands for completion
|
14
14
|
:list_suffixes, :submit_release
|
15
15
|
]
|
16
|
-
ACTION_HELP =
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
ACTION_HELP = {
|
17
|
+
:submit_release => "Push the tags to 'stable' remote and create the release packages",
|
18
|
+
:summary => "Displays a summary of the configuration and the branches git-maintain sees"
|
19
|
+
}
|
20
20
|
|
21
21
|
def self.load(path=".")
|
22
22
|
dir = Dir.pwd()
|
@@ -245,10 +245,6 @@ module GitMaintain
|
|
245
245
|
mail.puts `git show #{tag} --no-decorate -q | awk '!p;/^-----END PGP SIGNATURE-----/{p=1}'`
|
246
246
|
mail.puts ""
|
247
247
|
}
|
248
|
-
mail.puts "It's available at the normal places:"
|
249
|
-
mail.puts ""
|
250
|
-
mail.puts "git://github.com/#{@remote_stable}"
|
251
|
-
mail.puts "https://github.com/#{@remote_stable}/releases"
|
252
248
|
mail.close()
|
253
249
|
|
254
250
|
case @mail_format
|
@@ -320,7 +316,7 @@ module GitMaintain
|
|
320
316
|
end
|
321
317
|
|
322
318
|
log(:WARNING, "This will officially release these tags: #{new_tags.join(", ")}")
|
323
|
-
rep = GitMaintain::confirm(opts, "release them")
|
319
|
+
rep = GitMaintain::confirm(opts, "release them", true)
|
324
320
|
if rep != 'y' then
|
325
321
|
raise "Aborting.."
|
326
322
|
end
|
@@ -330,7 +326,7 @@ module GitMaintain
|
|
330
326
|
end
|
331
327
|
|
332
328
|
log(:WARNING, "Last chance to cancel before submitting")
|
333
|
-
rep= GitMaintain::confirm(opts, "submit these releases")
|
329
|
+
rep= GitMaintain::confirm(opts, "submit these releases", true)
|
334
330
|
if rep != 'y' then
|
335
331
|
raise "Aborting.."
|
336
332
|
end
|
data/lib/travis.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Morey-Chaisemartin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -45,6 +45,8 @@ files:
|
|
45
45
|
- bin/git-maintain
|
46
46
|
- git-maintain-completion.sh
|
47
47
|
- lib/addons/RDMACore.rb
|
48
|
+
- lib/addons/git-maintain.rb
|
49
|
+
- lib/azure.rb
|
48
50
|
- lib/branch.rb
|
49
51
|
- lib/ci.rb
|
50
52
|
- lib/common.rb
|
@@ -52,7 +54,7 @@ files:
|
|
52
54
|
- lib/travis.rb
|
53
55
|
homepage: https://github.com/nmorey/git-maintain
|
54
56
|
licenses:
|
55
|
-
-
|
57
|
+
- GPL-3.0
|
56
58
|
metadata: {}
|
57
59
|
post_install_message:
|
58
60
|
rdoc_options: []
|
@@ -69,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
71
|
- !ruby/object:Gem::Version
|
70
72
|
version: '0'
|
71
73
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.7.7
|
74
|
+
rubygems_version: 3.0.8
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: Your ultimate script for maintaining stable branches and releasing your project.
|