Skip to content

Commit

Permalink
Bunch of changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
it3xl committed Jan 2, 2018
1 parent f9b8821 commit 1999b11
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 39 deletions.
45 changes: 28 additions & 17 deletions changed_refs.awk
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,33 @@ BEGIN {
local_refs_prefix = "refs/remotes/";
remote_refs_prefix = "refs/heads/";

remote_1 = origin_1;
remote_2 = origin_2;
local_1 = prefix_1;
local_2 = prefix_2;
local_1 = "1 local ref " origin_1;
local_2 = "2 local ref " origin_2;
remote_1 = "1 remote ref " prefix_1;
remote_2 = "2 remote ref " prefix_2;

tty_attached = "/dev/tty";

tty_dbg("AWK debugging is ON");
tty_dbg_line("AWK debugging is ON");
}
BEGINFILE {
file_states();
}
{
if($2){
common_key();

refs[$3][dest]["sha"] = $1;
refs[$3][dest]["ref"] = $2;
if(!$2)
next;

prefix_name_key();
if(index($3, prefix_1) != 1 && index($3, prefix_2) != 1){
tty_dbg("next " $3 " " prefix_1 " " prefix_2);
next;
}

refs[$3][dest]["sha"] = $1;
refs[$3][dest]["ref"] = $2;
}
END {
dest = "";
origin = "";

# Action array variables.
split("", a_ff1); split("", a_ff2);
Expand Down Expand Up @@ -171,10 +175,10 @@ function actions_to_operations( ref, sha1, sha2){
op_fetch2[ref];
}
for(ref in a_solv){
if(!index(refs[ref][local_1]["ref"], local_1)){
if(!refs[ref][local_1]["sha"]){
op_solv_push1[ref];
}
if(!index(refs[ref][local_2]["ref"], local_2)){
if(!refs[ref][local_2]["sha"]){
op_solv_push2[ref];
}
op_solv_fetch1[ref];
Expand Down Expand Up @@ -270,18 +274,16 @@ function file_states() {
break;
case 3:
dest = local_1;
origin = remote_1;
break;
case 4:
dest = local_2;
origin = remote_2;
break;
}
}
function common_key() {
function prefix_name_key() {
# Generates a common key for all 4 locations of every ref.
$3 = $2
split($3, split_refs, local_refs_prefix origin "/");
split($3, split_refs, local_refs_prefix dest "/");
if(split_refs[2]){
# Removes "refs/remotes/current_origin/"
$3 = split_refs[2];
Expand Down Expand Up @@ -314,6 +316,7 @@ function generate_missing_refs(){
}
}


function tty(msg){
print msg >> tty_attached;
}
Expand All @@ -327,6 +330,14 @@ function tty_dbg(msg){
#print "Œ " msg >> tty_attached;
print "Œ " msg " Ð" >> tty_attached;
}
function tty_line_dbg(msg){
tty_dbg();
tty_dbg(msg);
}
function tty_dbg_line(msg){
tty_dbg(msg);
tty_dbg();
}

END{
close(tty_attached);
Expand Down
2 changes: 1 addition & 1 deletion repo_settings/sample_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project_folder=sample_repo


# A conventional prefix for refs for repo 1.
prefix_1=clie/nt_co/
prefix_1=client_co/
#url_1=https://your-repo1-url.org/git/my_repo.git
url_1="$path_git_sync/sample_repos/remote_$prefix_1"

Expand Down
21 changes: 0 additions & 21 deletions set_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ if [[ ${missed_repo_settings:+1} ]]; then
fi











# TODO: add a check that urls and prefixes must not be the same!











export prefix_1
export url_1
export prefix_2
Expand Down

0 comments on commit 1999b11

Please sign in to comment.